invert


Description:

public static HashMap<V,K> invert<K,V> (HashMap<K,V> map, HashFunc<V> hash_func, EqualFunc<V> equal_func, owned ConflictResolverFunc<K>? on_conflict = null)

Returns a new map with keys and values swapped.

If multiple entries map to the same value key, later entries overwrite earlier ones unless conflict resolver is provided.

Parameters:

map

the source map.

hash_func

hash function for value type V.

equal_func

equality function for value type V.

on_conflict

optional resolver for value-key collisions.

Returns:

a new inverted map.