putIfAbsent


Description:

public bool putIfAbsent (owned K key, owned V value)

Associates the value with the key only if the key is not already present. Returns true if the value was added.

Example:

    var map = new HashMap<string,string> (GLib.str_hash, GLib.str_equal);
assert (map.putIfAbsent ("key", "first"));
assert (!map.putIfAbsent ("key", "second"));
assert (map.get ("key") == "first");

Parameters:

key

the key.

value

the value to set if key is absent.

Returns:

true if the value was added.