Class IMaps
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> IMap <K, V> hashed()
Constructs an empty unsorted map.static <K,
V> IMap <K, V> Constructs an unsorted map.static <K,
V> IMap <K, V> Constructs an unsorted map.static <K,
V> IMapBuilder <K, V> Constructs a Builder to produce unsorted maps.static <K,
V> IMap <K, V> ordered()
Constructs an empty map whose iterators traverse elements in the same order that they were originally added to the map.static <K,
V> IMap <K, V> Constructs a map whose iterators traverse elements in the same order that they were originally added to the map.static <K,
V> IMap <K, V> Constructs a map whose iterators traverse elements in the same order that they were originally added to the map.static <K,
V> IMapBuilder <K, V> Create a Builder to construct maps whose iterators visit entries in the same order they were added to the map.static <K extends Comparable<K>,
V>
IMap<K, V> sorted()
Constructs an empty map that sorts keys in their natural sort order (using ComparableComparator).static <K,
V> IMap <K, V> sorted
(Comparator<K> comparator) Constructs a map that sorts keys using the specified Comparator.static <K,
V> IMap <K, V> sorted
(Comparator<K> comparator, Map<K, V> source) Constructs a map that sorts keys using the specified Comparator.static <K,
V> IMap <K, V> sorted
(Comparator<K> comparator, IMap<K, V> source) Constructs a map that sorts keys using the specified Comparator.static <K extends Comparable<K>,
V>
IMap<K, V> Constructs a map that sorts keys in their natural sort order (using ComparableComparator).static <K extends Comparable<K>,
V>
IMap<K, V> Constructs a map that sorts keys in their natural sort order (using ComparableComparator).static <K extends Comparable<K>,
V>
IMapBuilder<K, V> Create a Builder to construct sorted maps using the natural order of the keys.static <K,
V> IMapBuilder <K, V> sortedBuilder
(Comparator<K> comparator) Create a Builder to construct sorted maps using the specified Comparator for keys.
-
Method Details
-
hashed
Constructs an empty unsorted map.Implementation note: The map will adopt a hash code collision strategy based on the first key assigned to the map. All keys in the map must either implement Comparable (and be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous keys in any map.
-
hashed
Constructs an unsorted map. All key/value pairs from source are copied into the newly created map.Implementation note: The map will adopt a hash code collision strategy based on the first key in source. All keys in the map must either implement Comparable (and be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous keys in any map.
-
hashed
Constructs an unsorted map. If source is already an unsorted map it is returned directly, otherwise a new map is created and all key/value pairs from source are copied into the newly created map.Implementation note: The map will adopt a hash code collision strategy based on the first key in source. All keys in the map must either implement Comparable (and be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous keys in any map.
-
sorted
Constructs an empty map that sorts keys in their natural sort order (using ComparableComparator). -
sorted
Constructs a map that sorts keys in their natural sort order (using ComparableComparator). All key/value pairs from source are copied into the newly created map.- Parameters:
source
- java.util.Map containing starting key/value pairs
-
sorted
Constructs a map that sorts keys in their natural sort order (using ComparableComparator). All key/value pairs from source are copied into the newly created map. If source is already a sorted map using the natural sort order it will be returned directly (effectively performing a simple cast).- Parameters:
source
-IMap
containing starting key/value pairs
-
sorted
Constructs a map that sorts keys using the specified Comparator.Note that the Comparator MUST BE IMMUTABLE. The Comparator will be retained and used throughout the life of the map and its offspring and will be aggressively shared so it is imperative that the Comparator be completely immutable.
All key/value pairs from map are copied into the newly created map.
-
sorted
@Nonnull public static <K,V> IMap<K,V> sorted(@Nonnull Comparator<K> comparator, @Nonnull Map<K, V> source) Constructs a map that sorts keys using the specified Comparator.Note that the Comparator MUST BE IMMUTABLE. The Comparator will be retained and used throughout the life of the map and its offspring and will be aggressively shared so it is imperative that the Comparator be completely immutable.
All key/value pairs from source are copied into the newly created map.
- Parameters:
source
- java.util.Map containing starting key/value pairs
-
sorted
@Nonnull public static <K,V> IMap<K,V> sorted(@Nonnull Comparator<K> comparator, @Nonnull IMap<K, V> source) Constructs a map that sorts keys using the specified Comparator.Note that the Comparator MUST BE IMMUTABLE. The Comparator will be retained and used throughout the life of the map and its offspring and will be aggressively shared so it is imperative that the Comparator be completely immutable.
If source is already a sorted map that uses the same comparator (as indicated by comparator.equals()) then source will be returned directly. Otherwise all key/value pairs from source are copied into the newly created map.
- Parameters:
source
-IMap
containing starting key/value pairs
-
ordered
Constructs an empty map whose iterators traverse elements in the same order that they were originally added to the map. Similar to LinkedHapMap.The map will adopt a hash code collision strategy based on the first key assigned to the map. All keys in the map must either implement Comparable (and be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous keys in any map.
-
ordered
Constructs a map whose iterators traverse elements in the same order that they were originally added to the map. Similar to LinkedHapMap. All key/value pairs from source are copied into the newly created map.The map will adopt a hash code collision strategy based on the first key in source. All keys in the map must either implement Comparable (and be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous keys in any map.
-
ordered
Constructs a map whose iterators traverse elements in the same order that they were originally added to the map. Similar to LinkedHapMap. If source is already an in order map it is returned directly, otherwise a new map is created and all key/value pairs from source are copied into the newly created map. In this case the iteration order for those entries would be based on the order of elements returned by source's iterator.The map will adopt a hash code collision strategy based on the first key in source. All keys in the map must either implement Comparable (and be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous keys in any map.
-
hashedBuilder
Constructs a Builder to produce unsorted maps.Implementation note: The map will adopt a hash code collision strategy based on the first key added. All keys in the map must either implement Comparable (and be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous keys in any map.
-
sortedBuilder
Create a Builder to construct sorted maps using the natural order of the keys. -
sortedBuilder
Create a Builder to construct sorted maps using the specified Comparator for keys. -
orderedBuilder
Create a Builder to construct maps whose iterators visit entries in the same order they were added to the map.
-