Class SortedSet

A set that further guarantees that its iterator will traverse the set in ascending element order, sorted according to the natural ordering of its elements (only supported for Number, String, Date, Money and Quantity), or by a comparator provided at sorted set creation time.

ConstructorDescription
SortedSet()Constructor to create a new SortedSet.
SortedSet(Object)Constructor to create a new SortedSet.
SortedSet(Collection)Constructor for a new SortedSet.
MethodDescription
clone()Returns a shallow copy of this set.
first()Returns the first (lowest) element currently in this sorted set.
headSet(Object)Returns a view of the portion of this sorted set whose elements are strictly less than toElement.
last()Returns the last (highest) element currently in this sorted set.
subSet(Object, Object)Returns a view of the portion of this sorted set whose elements range from fromElement, inclusive, to toElement, exclusive.
tailSet(Object)Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement.

add, add1, addAll, clear, contains, containsAll, getLength, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

SortedSet()

Constructor to create a new SortedSet.


SortedSet(comparator: Object)

Constructor to create a new SortedSet.

The constructor takes a compare function as additional parameter. This comparator determines identity and the order of the elements for this set. The order of the elements is determined with a comparator (see PropertyComparator) or with the help of the given function. The function must take two parameters and return a value <=-1 if the first parameter is smaller than the second, a value if >=1 if the first one is greater than the second parameter and a value in between like 0 if both are equal.

Parameters:

  • comparator - an instance of a PropertyComparator or a comparison function

SortedSet(collection: Collection)

Constructor for a new SortedSet. The constructor initializes the SortedSet with the elements of the given collection.

Parameters:

  • collection - the collection of objects that are inserted into the set.

clone(): SortedSet

Returns a shallow copy of this set.

Returns:

  • a shallow copy of this set.

first(): Object

Returns the first (lowest) element currently in this sorted set.

Returns:

  • the first (lowest) element currently in this sorted set.

headSet(key: Object): SortedSet

Returns a view of the portion of this sorted set whose elements are strictly less than toElement. The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned sorted set supports all optional set operations.

Parameters:

  • key - high endpoint (exclusive) of the headSet.

Returns:

  • a view of the specified initial range of this sorted set.

last(): Object

Returns the last (highest) element currently in this sorted set.

Returns:

  • the last (highest) element currently in this sorted set.

subSet(from: Object, to: Object): SortedSet

Returns a view of the portion of this sorted set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned sorted set is empty.) The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned sorted set supports all optional set operations that this sorted set supports.

Parameters:

  • from - low endpoint (inclusive) of the subSet.
  • to - high endpoint (exclusive) of the subSet.

Returns:

  • a view of the specified range within this sorted set.

tailSet(key: Object): SortedSet

Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement. The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned sorted set supports all optional set operations.

Parameters:

  • key - low endpoint (inclusive) of the tailSet.

Returns:

  • a view of the specified final range of this sorted set.