Class EconomicMapUtil

java.lang.Object
org.graalvm.collections.EconomicMapUtil

public final class EconomicMapUtil extends Object
Utility methods for the EconomicMap.
Since:
23.0
  • 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 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 - the first map to be compared
      rhs - the second map to be compared
      Returns:
      true iff the maps are equal
      Since:
      23.0
    • hashCode

      public static <K, V> int hashCode(UnmodifiableEconomicMap<K,V> map)
      Computes an order-independent hash code for an EconomicMap.
      Parameters:
      map - the input map or null
      Returns:
      the hash code of the map
      Since:
      23.0
    • keySet

      public static <K, V> EconomicSet<K> keySet(EconomicMap<K,V> map)
      Returns an EconomicSet 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 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 - a comparator to compare keys
      valueComparator - a comparator to compare values
      Returns:
      a lexicographical map comparator
      Since:
      23.0