mapKeys


Description:

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

Returns a new map with transformed keys and preserved values.

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

Parameters:

map

the source map.

fn

key transformation function.

hash_func

hash function for transformed key type J.

equal_func

equality function for transformed key type J.

on_conflict

optional resolver for key collisions.

Returns:

a new map with transformed keys.