computeIfAbsentString


Description:

public static string computeIfAbsentString (HashMap<string,string> map, string key, owned SupplierFunc<string> fn)

Returns the value for the key. If the key is absent, computes the value using the supplier function, stores it in the map, and returns it.

Note:

this method modifies the original map when the key is absent.

Example:

    var cache = new HashMap<string, string> (GLib.str_hash, GLib.str_equal);
var val = Maps.computeIfAbsentString (cache, "key", () => {
return "computed";
});
// val == "computed", cache["key"] == "computed"

Parameters:

map

the map to query and potentially update.

key

the key to look up.

fn

the supplier function to compute the value if absent.

Returns:

the existing or newly computed value.