Interface ISet<T>

All Superinterfaces:
ICollection<T>, InvariantCheckable, IStreamable<T>, Iterable<T>, Mapped<T,T>, Serializable, SplitableIterable<T>
All Known Subinterfaces:
IMultiset<T>
All Known Implementing Classes:
AbstractMultiset, AbstractSet, AbstractSetUsingMap, EmptyHashSet, HashMultiset, HashSet, OrderedMultiset, OrderedSet, TreeMultiset, TreeSet

@Immutable public interface ISet<T> extends ICollection<T>, Mapped<T,T>, InvariantCheckable, Serializable
Interface for immutable sets.
  • Method Details

    • insert

      @Nonnull ISet<T> insert(@Nonnull T value)
      Adds the single value to the Set.
      Specified by:
      insert in interface ICollection<T>
      Returns:
      instance of set containing the value
    • insertAll

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

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

      boolean contains(@Nullable T value)
      Determines if the Set contains the specified value.
      Returns:
      true if the Set contains the value
    • containsAll

      boolean containsAll(@Nonnull Iterable<? extends T> values)
      Determines if the Set contains all values in the specified collection.
      Returns:
      true if the Set contains the values
    • containsAll

      boolean containsAll(@Nonnull Iterator<? extends T> values)
      Determines if the Set contains all values in the specified collection.
      Returns:
      true if the Set contains the values
    • containsAny

      boolean containsAny(@Nonnull Iterable<? extends T> values)
      Determines if the Set contains any values in the specified collection.
      Returns:
      true if the Set contains a value
    • containsAny

      boolean containsAny(@Nonnull Iterator<? extends T> values)
      Determines if the Set contains any values in the specified collection.
      Returns:
      true if the Set contains a value
    • delete

      @Nonnull ISet<T> delete(T value)
      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 ISet<T> deleteAll(@Nonnull Iterable<? extends T> other)
      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
    • deleteAll

      @Nonnull ISet<T> deleteAll(@Nonnull Iterator<? extends T> other)
      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 ISet<T> union(@Nonnull Iterable<? extends T> other)
      Adds all values from other to the Set.
      Parameters:
      other - source of values to add
      Returns:
      instance of set containing the values
    • union

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

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

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

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

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

      @Nonnull ISet<T> deleteAll()
      Specified by:
      deleteAll in interface ICollection<T>
      Returns:
      an equivalent collection with no values
    • getSet

      @Nonnull Set<T> getSet()
      Returns:
      an unmodifiable Set implementation backed by this set.
    • get

      @Nullable default T get(T key)
      Returns the specified key if its contained in the set. Otherwise returns null.
      Specified by:
      get in interface Mapped<T,T>
      Parameters:
      key - identifies the value to retrieve
      Returns:
      the key or null
    • getValueOr

      default T getValueOr(T key, T defaultValue)
      Returns the specified key if its contained in the set. Otherwise returns defaultValue.
      Specified by:
      getValueOr in interface Mapped<T,T>
      Parameters:
      key - identifies the value to retrieve
      defaultValue - value to return if no entry exists for key
      Returns:
      the key or defaultValue
    • find

      @Nonnull default Maybe<T> find(T key)
      Returns a Holder containing the specified key if its contained in the set. Otherwise returns an empty Holder.
      Specified by:
      find in interface Mapped<T,T>
      Parameters:
      key - identifies the value to retrieve
      Returns:
      possibly empty Holder
    • select

      @Nonnull default ISet<T> select(@Nonnull java.util.function.Predicate<T> predicate)
      Returns a set of the same type as this containing only those elements for which predicate returns true. Implementations are optimized assuming predicate will return false more often than true.
      Parameters:
      predicate - decides whether to include an element
      Returns:
      set of same type as this containing only those elements for which predicate returns true
    • reject

      @Nonnull default ISet<T> reject(@Nonnull java.util.function.Predicate<T> predicate)
      Returns a set of the same type as this containing all those elements for which predicate returns false. Implementations are optimized assuming predicate will return false more often than true.
      Parameters:
      predicate - decides whether to include an element
      Returns:
      set of same type as this containing only those elements for which predicate returns false
    • setCollector

      @Nonnull default java.util.stream.Collector<T,?,ISet<T>> setCollector()
      Returns a Collector that creates a set of the same type as this containing all of the collected values inserted over whatever starting values this already contained.