Class SortedSet<V>

All Implemented Interfaces:
ICollection<ISet<V>,V>, ISet<V>, ISortedSet<V>, Iterable<V>, Predicate<V>

public class SortedSet<V> extends ISortedSet.Mixin<V>
  • Constructor Details

    • SortedSet

      public SortedSet()
    • SortedSet

      public SortedSet(Comparator<V> comparator)
  • Method Details

    • comparator

      public Comparator<V> comparator()
    • inclusiveFloorIndex

      public OptionalLong inclusiveFloorIndex(V val)
      Returns:
      the entry whose key is either equal to key, or just below it. If key is less than the minimum value in the map, returns null.
    • ceilIndex

      public OptionalLong ceilIndex(V val)
      Returns:
      the entry whose key is either equal to key, or just above it. If key is greater than the maximum value in the map, returns null.
    • add

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

      public SortedSet<V> remove(V value)
      Returns:
      the set, without value
    • zip

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

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

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

      public boolean contains(V value)
      Returns:
      true, if the set contains value
    • indexOf

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

      public long size()
      Returns:
      the number of elements in the collection
    • nth

      public V nth(long idx)
      Returns:
      the element at idx
    • elements

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

      public boolean isLinear()
      Returns:
      true, if the set is linear
    • forked

      public SortedSet<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.

      Returns:
      a forked form of the data structure
    • linear

      public SortedSet<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.

      Returns:
      a linear form of this data structure