saker.build Documentation TaskDoc JavaDoc Packages
public abstract class SetTransformingSortedMap<E, K, Vextends SetTransformingMap<E, K, V> implements SortedMap<K, V>
Pseudo-Map implementation that is backed by a set and dynamically generates the entries for it based on an element value.

This map works the same way as SetTransformingMap, but also implements SortedMap.

A comparator can be specified during the construction of this map, which will be reported when comparator() is called. When this map is used as the argument to a constructor of a sorted map (E.g. TreeMap.TreeMap(SortedMap<K, ? extends V>)), this will cause the constructed map to have the same ordering as this map.

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

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

EThe element type of the set.
KThe key type of this map.
VThe value type of this map.
Fields
protected final Comparator<super K>
The comparator that this map is ordered by.
Constructors
public
SetTransformingSortedMap(Set<extends E> set)
Creates a new instance with the given set.
public
SetTransformingSortedMap(Set<extends E> set, Comparator<super K> comparator)
Creates a new instance with the given set and comparator.
Methods
public Comparator<super K>
Returns the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys.
public K
Returns the first (lowest) key currently in this map.
public SortedMap<K, V>
headMap(K toKey)
Returns a view of the portion of this map whose keys are strictly less than toKey.
public K
Returns the last (highest) key currently in this map.
public SortedMap<K, V>
subMap(K fromKey, K toKey)
Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
public SortedMap<K, V>
tailMap(K fromKey)
Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
protected final Comparator<super K> comparator
The comparator that this map is ordered by.
public SetTransformingSortedMap(Set<extends E> set) throws NullPointerException
Creates a new instance with the given set.
setThe subject set.
NullPointerExceptionIf the set is null.
public SetTransformingSortedMap(Set<extends E> set, Comparator<super K> 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 K> comparator()
Overridden from: SortedMap
Returns the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys.
the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys
public K firstKey()
Overridden from: SortedMap
Returns the first (lowest) key currently in this map.
the first (lowest) key currently in this map
public SortedMap<K, V> headMap(K toKey)
Overridden from: SortedMap
Returns a view of the portion of this map whose keys are strictly less than toKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

toKeyhigh endpoint (exclusive) of the keys in the returned map
a view of the portion of this map whose keys are strictly less than toKey
public K lastKey()
Overridden from: SortedMap
Returns the last (highest) key currently in this map.
the last (highest) key currently in this map
public SortedMap<K, V> subMap(K fromKey, K toKey)
Overridden from: SortedMap
Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal, the returned map is empty.) The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

fromKeylow endpoint (inclusive) of the keys in the returned map
toKeyhigh endpoint (exclusive) of the keys in the returned map
a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive
public SortedMap<K, V> tailMap(K fromKey)
Overridden from: SortedMap
Returns a view of the portion of this map whose keys are greater than or equal to fromKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

fromKeylow endpoint (inclusive) of the keys in the returned map
a view of the portion of this map whose keys are greater than or equal to fromKey