saker.util Documentation TaskDoc JavaDoc Packages
package saker.util
public abstract class TransformingSortedSet<SE, Eextends TransformingSet<SE, E> implements SortedSet<E>
Pseudo-Set implementation that dynamically generated the elements for it based on the elements of a subject set.

This set works the same way as TransformingSet, but also implements SortedSet.

A comparator can be specified during the construction of this set, which will be reported when comparator() is called. When this set is used as the argument to a constructor of a sorted set (E.g. TreeSet.TreeSet(SortedSet<E>)), this will cause the constructed set to have the same ordering as this set.

Important: Implementations should ensure that the transformed elements are ordered by the comparator of this constructed set. Violating this may result in undefined behaviour in some implementations.

The use-case for this map is the same as for TransformingSet. See the documentation of that class for more information.

SEThe source set element type.
EThe element type of this set.
Fields
protected final Comparator<super E>
The comparator that this set is ordered by.
Constructors
public
TransformingSortedSet(SortedSet<extends SE> set)
Creates a new instance with the given set.
public
TransformingSortedSet(SortedSet<extends SE> set, Comparator<super E> comparator)
Creates a new instance with the given set and comparator.
Methods
public Comparator<super E>
Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.
public E
Returns the first (lowest) element currently in this set.
public SortedSet<E>
headSet(E toElement)
Returns a view of the portion of this set whose elements are strictly less than toElement.
public E
Returns the last (highest) element currently in this set.
public SortedSet<E>
subSet(E fromElement, E toElement)
Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
public SortedSet<E>
tailSet(E fromElement)
Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
protected final Comparator<super E> comparator
The comparator that this set is ordered by.
public TransformingSortedSet(SortedSet<extends SE> set) throws NullPointerException
Creates a new instance with the given set.
setThe subject set.
NullPointerExceptionIf the set is null.
public TransformingSortedSet(SortedSet<extends SE> set, Comparator<super E> comparator) throws NullPointerException
Creates a new instance with the given set and comparator.
setThe subject set.
comparatorThe comparator.
NullPointerExceptionIf the set is null.
public Comparator<super E> comparator()
Overridden from: SortedSet
Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.
the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements
public E first()
Overridden from: SortedSet
Returns the first (lowest) element currently in this set.
the first (lowest) element currently in this set
public SortedSet<E> headSet(E toElement)
Overridden from: SortedSet
Returns a view of the portion of this set whose elements are strictly less than toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

toElementhigh endpoint (exclusive) of the returned set
a view of the portion of this set whose elements are strictly less than toElement
public E last()
Overridden from: SortedSet
Returns the last (highest) element currently in this set.
the last (highest) element currently in this set
public SortedSet<E> subSet(E fromElement, E toElement)
Overridden from: SortedSet
Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

fromElementlow endpoint (inclusive) of the returned set
toElementhigh endpoint (exclusive) of the returned set
a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive
public SortedSet<E> tailSet(E fromElement)
Overridden from: SortedSet
Returns a view of the portion of this set whose elements are greater than or equal to fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

fromElementlow endpoint (inclusive) of the returned set
a view of the portion of this set whose elements are greater than or equal to fromElement