dw.util
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.
Constructor Summary
SortedSet()
Constructor to create a new SortedSet.
SortedSet(collection
:
Collection)
Constructor for a new SortedSet.
Method Summary
headSet(key
:
Object)
:
SortedSet
Returns a view of the portion of this sorted set whose elements are strictly less than toElement.
Methods inherited from class
Collection
Methods inherited from class
Object
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
Constructor Detail
SortedSet
public 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
public 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.
Method Detail
first
first()
:
Object
Returns the first (lowest) element currently in this sorted set.
Returns:
the first (lowest) element currently in this sorted set.
headSet
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
last()
:
Object
Returns the last (highest) element currently in this sorted set.
Returns:
the last (highest) element currently in this sorted set.
subSet
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
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.