Interface ISet<V>

All Superinterfaces:
ICollection<ISet<V>,V>, Iterable<V>, Predicate<V>
All Known Subinterfaces:
ISortedSet<V>
All Known Implementing Classes:
IntSet, ISet.Mixin, ISortedSet.Mixin, LinearSet, Set, SortedSet

public interface ISet<V> extends ICollection<ISet<V>,V>, Predicate<V>
  • Method Details

    • valueHash

      ToLongFunction<V> valueHash()
      Returns:
      the hash function used by the set
    • valueEquality

      BiPredicate<V,V> valueEquality()
      Returns:
      the equality semantics used by the set
    • contains

      default boolean contains(V value)
      Returns:
      true, if the set contains value
    • elements

      default IList<V> elements()
      Returns:
      a list containing all the elements in the set
    • zip

      default <U> IMap<V,U> zip(Function<V,U> f)
      Returns:
      a map which has a corresponding value, computed by f, for each element in the set
    • indexOf

      OptionalLong indexOf(V element)
      Returns:
      the position of element in the collection, if it's present
    • containsAll

      default boolean containsAll(ISet<V> set)
      Returns:
      true if this set contains every element in set
    • containsAll

      default boolean containsAll(IMap<V,?> map)
      Returns:
      true if this set contains every key in map
    • containsAny

      default boolean containsAny(ISet<V> set)
      Returns:
      true if this set contains any element in set
    • containsAny

      default boolean containsAny(IMap<V,?> map)
      Returns:
      true if this set contains any key in map
    • add

      ISet<V> add(V value)
      Returns:
      the set, containing value
    • remove

      ISet<V> remove(V value)
      Returns:
      the set, without value
    • iterator

      default Iterator<V> iterator(long startIndex)
      Specified by:
      iterator in interface ICollection<ISet<V>,V>
      Returns:
      an iterator representing the elements of the set
    • spliterator

      default Spliterator<V> spliterator()
      Specified by:
      spliterator in interface Iterable<V>
    • stream

      default Stream<V> stream()
      Returns:
      a Stream, representing the elements in the set
    • union

      default ISet<V> union(ISet<V> set)
      Returns:
      a new set, representing the union with set
    • difference

      default ISet<V> difference(ISet<V> set)
      Returns:
      a new set, representing the difference with set
    • intersection

      default ISet<V> intersection(ISet<V> set)
      Returns:
      a new set, representing the intersection with set
    • toSet

      default Set<V> toSet()
      Returns:
      the collection, represented as a normal Java set, which will throw UnsupportedOperationException on writes
    • toArray

      default Object[] toArray()
      Returns:
      the elements of the list, in an array
    • toArray

      default V[] toArray(IntFunction<V[]> allocator)
      Parameters:
      allocator - a function which creates an array of the specified size
      Returns:
      the elements of the list, in a typed array
    • isLinear

      default boolean isLinear()
      Specified by:
      isLinear in interface ICollection<ISet<V>,V>
      Returns:
      true, if the set is linear
    • forked

      default ISet<V> forked()
      Description copied from interface: ICollection
      This returns a data structure which is forked, which is equivalent to Clojure's persistent data structures, also sometimes called functional or immutable. This is called "forked" because it means that multiple functions can make divergent changes to the data structure without affecting each other.

      If only a single function or scope uses the data structure, it can be left as a linear data structure, which can have significant performance benefits.

      If the data structure is already forked, it will simply return itself.

      Specified by:
      forked in interface ICollection<ISet<V>,V>
      Returns:
      a forked form of the data structure
    • linear

      ISet<V> linear()
      Description copied from interface: ICollection
      This returns a data structure which is linear, or temporarily mutable. The term "linear", as used here, does not completely align with the formal definition of linear types as used in type theory. It is meant to describe the linear dataflow of the method calls, and as a converse to "forked" data structures.

      If ICollection.forked() is called on a linear collection, all references to that linear collection should be discarded.

      If the data structure is already linear, it will simply return itself.

      Specified by:
      linear in interface ICollection<ISet<V>,V>
      Returns:
      a linear form of this data structure
    • sliceIndices

      default ISet<V> sliceIndices(long startIndex, long endIndex)
    • split

      default IList<? extends ISet<V>> split(int parts)
      Description copied from interface: ICollection
      Splits the collection into roughly even pieces, for parallel processing. Depending on the size and contents of the collection, this function may not return exactly parts subsets.
      Specified by:
      split in interface ICollection<ISet<V>,V>
      Parameters:
      parts - the target number of pieces
      Returns:
      a list containing subsets of the collection.
    • test

      default boolean test(V v)
      Specified by:
      test in interface Predicate<V>