Top Description Constructors Methods
org.graalvm.collections

public final Class EconomicMapUtil

extends Object
Class Inheritance
Imports
java.util.Comparator, .Objects

Utility methods for the EconomicMap.
Since
23.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <K, V> boolean

Returns:

true iff the maps are equal
equals
(UnmodifiableEconomicMap<K, V>
the first map to be compared
lhs
,
UnmodifiableEconomicMap<K, V>
the second map to be compared
rhs
)

Compares maps for equality.

public static <K, V> int

Returns:

the hash code of the map
hashCode
(UnmodifiableEconomicMap<K, V>
the input map or null
map
)

Computes an order-independent hash code for an EconomicMap.

public static <K, V> EconomicSet<K>

Returns:

an EconomicSet of the keys contained in a map
keySet
(EconomicMap<K, V>
the input map
map
)

Returns an EconomicSet of the keys contained in a map.

public static <K, V> Comparator<UnmodifiableEconomicMap<K, V>>

Returns:

a lexicographical map comparator
lexicographicalComparator
(Comparator<K>
a comparator to compare keys
keyComparator
,
Comparator<V>
a comparator to compare values
valueComparator
)

Creates a lexicographical map comparator using the provided key and value comparators.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EconomicMapUtilback to summary
private EconomicMapUtil()
Since
23.0

Method Detail

equalsback to summary
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 same equivalence strategy, their keys are equal with respect to the strategy and the values are equal as determined by the equals method.

Parameters
lhs:UnmodifiableEconomicMap<K, V>

the first map to be compared

rhs:UnmodifiableEconomicMap<K, V>

the second map to be compared

Returns:boolean

true iff the maps are equal

Since
23.0
hashCodeback to summary
public static <K, V> int hashCode(UnmodifiableEconomicMap<K, V> map)

Computes an order-independent hash code for an EconomicMap.

Parameters
map:UnmodifiableEconomicMap<K, V>

the input map or null

Returns:int

the hash code of the map

Since
23.0
keySetback to summary
public static <K, V> EconomicSet<K> keySet(EconomicMap<K, V> map)

Returns an EconomicSet of the keys contained in a map.

Parameters
map:EconomicMap<K, V>

the input map

Returns:EconomicSet<K>

an EconomicSet of the keys contained in a map

Since
23.0
lexicographicalComparatorback to summary
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 their key1 and if they are equal, it goes on to compare value1, then key2, value2 and so on. If one of the maps is shorter, the comparators are called with null values in place of the missing keys/values.

Parameters
keyComparator:Comparator<K>

a comparator to compare keys

valueComparator:Comparator<V>

a comparator to compare values

Returns:Comparator<UnmodifiableEconomicMap<K, V>>

a lexicographical map comparator

Since
23.0