Class AbstractSetUsingMap<T>

java.lang.Object
org.javimmutable.collections.common.AbstractSet<T>
org.javimmutable.collections.common.AbstractSetUsingMap<T>
All Implemented Interfaces:
Serializable, Iterable<T>, ICollection<T>, InvariantCheckable, ISet<T>, IStreamable<T>, Mapped<T,T>, SplitableIterable<T>
Direct Known Subclasses:
OrderedSet, TreeSet

public abstract class AbstractSetUsingMap<T> extends AbstractSet<T>
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • insert

      @Nonnull public ISet<T> insert(@Nonnull T value)
      Description copied from interface: ISet
      Adds the single value to the Set.
      Returns:
      instance of set containing the value
    • contains

      public boolean contains(@Nullable T value)
      Description copied from interface: ISet
      Determines if the Set contains the specified value.
      Returns:
      true if the Set contains the value
    • delete

      @Nonnull public ISet<T> delete(T value)
      Description copied from interface: ISet
      Removes the value from the Set. Has no effect if the value is not in the Set.
      Returns:
      instance of set without the value
    • deleteAll

      @Nonnull public ISet<T> deleteAll(@Nonnull Iterator<? extends T> values)
      Description copied from interface: ISet
      Removes all values of other from the Set. Has no effect if none of the values are in the Set
      Returns:
      instance of set without the values
    • union

      @Nonnull public ISet<T> union(@Nonnull Iterator<? extends T> values)
      Description copied from interface: ISet
      Adds all values from other to the Set.
      Parameters:
      values - source of values to add
      Returns:
      instance of set containing the values
    • intersection

      @Nonnull public ISet<T> intersection(@Nonnull Iterator<? extends T> values)
      Description copied from interface: ISet
      Removes all values from the Set that are not contained in the other collection.
      Returns:
      instance of set with unmatched values removed
    • intersection

      @Nonnull public ISet<T> intersection(@Nonnull Set<? extends T> other)
      Description copied from interface: ISet
      Removes all values from the Set that are not contained in the other collection.
      Returns:
      instance of set with unmatched values removed
    • size

      public int size()
      Returns:
      number of values in the collection
    • isEmpty

      public boolean isEmpty()
      Returns:
      true only if collection contains no values
    • iterator

      @Nonnull public SplitableIterator<T> iterator()
      Description copied from interface: IStreamable
      Overridden here to require implementations to return a SplitableIterator rather than a basic Iterator. This is necessary to allow composition of new objects from methods like keys() and values().
    • getSpliteratorCharacteristics

      public int getSpliteratorCharacteristics()
      Returns:
      characteristics value used when creating Spliterators
    • checkInvariants

      public void checkInvariants()
      Description copied from interface: InvariantCheckable
      Checks invariants of implementing class.
    • checkSetInvariants

      protected void checkSetInvariants()
    • create

      protected abstract ISet<T> create(IMap<T,Boolean> map)
      Implemented by derived classes to create a new instance of the appropriate class.