invertString


Description:

public static HashMap<string,string> invertString (HashMap<string,string> map, owned ConflictResolverFunc<string>? on_conflict = null)

Returns a new map with keys and values swapped. If multiple entries have the same value, later entries overwrite earlier ones in the result unless conflict resolver is provided.

Example:

    var map = new HashMap<string, string> (GLib.str_hash, GLib.str_equal);
map.put ("a", "1");
map.put ("b", "2");
var inv = Maps.invertString (map);
// inv["1"] == "a", inv["2"] == "b"

Parameters:

map

the source map.

on_conflict

optional resolver for value-key collisions.

Returns:

a new HashMap with keys and values swapped.