Package org.graalvm.collections
Class EconomicMapUtil
java.lang.Object
org.graalvm.collections.EconomicMapUtil
Utility methods for the
EconomicMap
.- Since:
- 23.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> boolean equals
(UnmodifiableEconomicMap<K, V> lhs, UnmodifiableEconomicMap<K, V> rhs) Compares maps for equality.static <K,
V> int hashCode
(UnmodifiableEconomicMap<K, V> map) Computes an order-independent hash code for anEconomicMap
.static <K,
V> EconomicSet <K> keySet
(EconomicMap<K, V> map) Returns anEconomicSet
of the keys contained in a map.static <K,
V> Comparator <UnmodifiableEconomicMap<K, V>> lexicographicalComparator
(Comparator<K> keyComparator, Comparator<V> valueComparator) Creates a lexicographical map comparator using the provided key and value comparators.
-
Method Details
-
equals
public static <K,V> boolean equals(UnmodifiableEconomicMap<K, V> lhs, UnmodifiableEconomicMap<K, V> rhs) Compares maps for equality. The maps are equal iff they share the sameequivalence strategy
, their keys are equal with respect to the strategy and the values are equal as determined by theequals
method.- Parameters:
lhs
- the first map to be comparedrhs
- the second map to be compared- Returns:
true
iff the maps are equal- Since:
- 23.0
-
hashCode
Computes an order-independent hash code for anEconomicMap
.- Parameters:
map
- the input map ornull
- Returns:
- the hash code of the map
- Since:
- 23.0
-
keySet
Returns anEconomicSet
of the keys contained in a map.- Parameters:
map
- the input map- Returns:
- an
EconomicSet
of the keys contained in a map - Since:
- 23.0
-
lexicographicalComparator
public static <K,V> Comparator<UnmodifiableEconomicMap<K,V>> lexicographicalComparator(Comparator<K> keyComparator, Comparator<V> valueComparator) Creates a lexicographical map comparator using the provided key and value comparators. The maps are treated as if they were lists with the structure{key1, value1, key2, value2, ...}
. The comparison starts by comparing theirkey1
and if they are equal, it goes on to comparevalue1
, thenkey2
,value2
and so on. If one of the maps is shorter, the comparators are called withnull
values in place of the missing keys/values.- Parameters:
keyComparator
- a comparator to compare keysvalueComparator
- a comparator to compare values- Returns:
- a lexicographical map comparator
- Since:
- 23.0
-