Class AbstractSet<T>

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

@Immutable public abstract class AbstractSet<T> extends Object implements ISet<T>
See Also:
  • Constructor Details

    • AbstractSet

      public AbstractSet()
  • Method Details

    • insertAll

      @Nonnull public ISet<T> insertAll(@Nonnull Iterable<? extends T> values)
      Description copied from interface: ISet
      Adds all of the elements of the specified collection to the set.
      Specified by:
      insertAll in interface ICollection<T>
      Specified by:
      insertAll in interface ISet<T>
      Returns:
      instance of set containing the collection
    • insertAll

      @Nonnull public ISet<T> insertAll(@Nonnull Iterator<? extends T> values)
      Description copied from interface: ISet
      Adds all of the elements of the specified collection to the set.
      Specified by:
      insertAll in interface ICollection<T>
      Specified by:
      insertAll in interface ISet<T>
      Returns:
      instance of set containing the collection
    • containsAll

      public boolean containsAll(@Nonnull Iterable<? extends T> values)
      Description copied from interface: ISet
      Determines if the Set contains all values in the specified collection.
      Specified by:
      containsAll in interface ISet<T>
      Returns:
      true if the Set contains the values
    • containsAll

      public boolean containsAll(@Nonnull Iterator<? extends T> values)
      Description copied from interface: ISet
      Determines if the Set contains all values in the specified collection.
      Specified by:
      containsAll in interface ISet<T>
      Returns:
      true if the Set contains the values
    • containsAny

      public boolean containsAny(@Nonnull Iterable<? extends T> values)
      Description copied from interface: ISet
      Determines if the Set contains any values in the specified collection.
      Specified by:
      containsAny in interface ISet<T>
      Returns:
      true if the Set contains a value
    • containsAny

      public boolean containsAny(@Nonnull Iterator<? extends T> values)
      Description copied from interface: ISet
      Determines if the Set contains any values in the specified collection.
      Specified by:
      containsAny in interface ISet<T>
      Returns:
      true if the Set contains a value
    • deleteAll

      @Nonnull public ISet<T> deleteAll(@Nonnull Iterable<? extends T> other)
      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
      Specified by:
      deleteAll in interface ISet<T>
      Returns:
      instance of set without the values
    • union

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

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

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

      @Nonnull public Set<T> getSet()
      Specified by:
      getSet in interface ISet<T>
      Returns:
      an unmodifiable Set implementation backed by this set.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • emptyMutableSet

      protected abstract Set<T> emptyMutableSet()
      Implemented by derived classes to create a new empty Set