Package it.unimi.dsi.fastutil.objects
Class Reference2ReferenceSortedMaps
java.lang.Object
it.unimi.dsi.fastutil.objects.Reference2ReferenceSortedMaps
A class providing static methods and objects that do useful things with type-specific sorted
maps.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An immutable class representing an empty type-specific sorted map.static class
An immutable class representing a type-specific singleton sorted map.static class
A synchronized wrapper class for sorted maps.static class
An unmodifiable wrapper class for sorted maps. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Reference2ReferenceSortedMaps.EmptySortedMap
An empty sorted map (immutable). -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> Reference2ReferenceSortedMap<K, V> emptyMap()
Returns an empty sorted map (immutable).static <K> Comparator<? super Map.Entry<K,
?>> entryComparator
(Comparator<? super K> comparator) Returns a comparator for entries based on a given comparator on keys.static <K,
V> ObjectBidirectionalIterable<Reference2ReferenceMap.Entry<K, V>> fastIterable
(Reference2ReferenceSortedMap<K, V> map) static <K,
V> ObjectBidirectionalIterator<Reference2ReferenceMap.Entry<K, V>> fastIterator
(Reference2ReferenceSortedMap<K, V> map) static <K,
V> Reference2ReferenceSortedMap<K, V> singleton
(K key, V value) Returns a type-specific immutable sorted map containing only the specified pair.static <K,
V> Reference2ReferenceSortedMap<K, V> singleton
(K key, V value, Comparator<? super K> comparator) Returns a type-specific immutable sorted map containing only the specified pair.static <K,
V> Reference2ReferenceSortedMap<K, V> Returns a synchronized type-specific sorted map backed by the given type-specific sorted map.static <K,
V> Reference2ReferenceSortedMap<K, V> synchronize
(Reference2ReferenceSortedMap<K, V> m, Object sync) Returns a synchronized type-specific sorted map backed by the given type-specific sorted map, using an assigned object to synchronize.static <K,
V> Reference2ReferenceSortedMap<K, V> unmodifiable
(Reference2ReferenceSortedMap<K, ? extends V> m) Returns an unmodifiable type-specific sorted map backed by the given type-specific sorted map.
-
Field Details
-
EMPTY_MAP
An empty sorted map (immutable). It is serializable and cloneable.
-
-
Method Details
-
entryComparator
public static <K> Comparator<? super Map.Entry<K,?>> entryComparator(Comparator<? super K> comparator) Returns a comparator for entries based on a given comparator on keys.- Parameters:
comparator
- a comparator on keys.- Returns:
- the associated comparator on entries.
-
fastIterator
public static <K,V> ObjectBidirectionalIterator<Reference2ReferenceMap.Entry<K,V>> fastIterator(Reference2ReferenceSortedMap<K, V> map) Returns a bidirectional iterator that will be fast, if possible, on the entry set of the providedmap
.- Parameters:
map
- a map from which we will try to extract a (fast) bidirectional iterator on the entry set.- Returns:
- a bidirectional iterator on the entry set of the given map that will be fast, if possible.
- Since:
- 8.0.0
-
fastIterable
public static <K,V> ObjectBidirectionalIterable<Reference2ReferenceMap.Entry<K,V>> fastIterable(Reference2ReferenceSortedMap<K, V> map) Returns an iterable yielding a bidirectional iterator that will be fast, if possible, on the entry set of the providedmap
.- Parameters:
map
- a map from which we will try to extract an iterable yielding a (fast) bidirectional iterator on the entry set.- Returns:
- an iterable yielding a bidirectional iterator on the entry set of the given map that will be fast, if possible.
- Since:
- 8.0.0
-
emptyMap
Returns an empty sorted map (immutable). It is serializable and cloneable.This method provides a typesafe access to
EMPTY_MAP
.- Returns:
- an empty sorted map (immutable).
-
singleton
Returns a type-specific immutable sorted map containing only the specified pair. The returned sorted map is serializable and cloneable.Note that albeit the returned map is immutable, its default return value may be changed.
- Parameters:
key
- the only key of the returned sorted map.value
- the only value of the returned sorted map.- Returns:
- a type-specific immutable sorted map containing just the pair
<key,value>
.
-
singleton
public static <K,V> Reference2ReferenceSortedMap<K,V> singleton(K key, V value, Comparator<? super K> comparator) Returns a type-specific immutable sorted map containing only the specified pair. The returned sorted map is serializable and cloneable.Note that albeit the returned map is immutable, its default return value may be changed.
- Parameters:
key
- the only key of the returned sorted map.value
- the only value of the returned sorted map.comparator
- the comparator to use in the returned sorted map.- Returns:
- a type-specific immutable sorted map containing just the pair
<key,value>
.
-
synchronize
public static <K,V> Reference2ReferenceSortedMap<K,V> synchronize(Reference2ReferenceSortedMap<K, V> m) Returns a synchronized type-specific sorted map backed by the given type-specific sorted map.- Parameters:
m
- the sorted map to be wrapped in a synchronized sorted map.- Returns:
- a synchronized view of the specified sorted map.
- See Also:
-
synchronize
public static <K,V> Reference2ReferenceSortedMap<K,V> synchronize(Reference2ReferenceSortedMap<K, V> m, Object sync) Returns a synchronized type-specific sorted map backed by the given type-specific sorted map, using an assigned object to synchronize.- Parameters:
m
- the sorted map to be wrapped in a synchronized sorted map.sync
- an object that will be used to synchronize the access to the sorted sorted map.- Returns:
- a synchronized view of the specified sorted map.
- See Also:
-
unmodifiable
public static <K,V> Reference2ReferenceSortedMap<K,V> unmodifiable(Reference2ReferenceSortedMap<K, ? extends V> m) Returns an unmodifiable type-specific sorted map backed by the given type-specific sorted map.- Parameters:
m
- the sorted map to be wrapped in an unmodifiable sorted map.- Returns:
- an unmodifiable view of the specified sorted map.
- See Also:
-