API: ISet

ISet is the interface for collections of unique elements, analogous to java.util.Set.

Key Methods

ISet<V> add(V value)

Returns a new set containing the specified value. If the value is already present, it returns an identical set.

ISet<V> remove(V value)

Returns a new set that does not contain the specified value.

boolean contains(V value)

Returns true if the set contains the specified value.

ISet<V> union(ISet<V> set)

Returns a new set containing all elements from this set and the other set.

ISet<V> difference(ISet<V> set)

Returns a new set containing elements that are in this set but not in the other set.

ISet<V> intersection(ISet<V> set)

Returns a new set containing only the elements that are present in both sets.

IList<V> elements()

Returns a list view of the elements in the set.

<U> IMap<V, U> zip(Function<V, U> f)

Returns a map where each element in the set is a key, and the corresponding value is computed by the provided function f.


API: ISortedSet

ISortedSet extends ISet for sets that maintain their elements in a sorted order.

Additional Methods

Comparator<V> comparator()

Returns the Comparator used to order the elements.

V floor(V value)

Returns the greatest element in this set less than or equal to the given value, or null if there is no such element.

V ceil(V value)

Returns the least element in this set greater than or equal to the given value, or null if there is no such element.

V first()

Returns the first element in the sorted set.

V last()

Returns the last element in the sorted set.