StringMap.get

Looks up key; if it exists returns corresponding value else evaluates and returns defaultValue.

Complexity: O(log(s)), where s is the number of the keys with the same length as the input key.

struct StringMap(T, U = uint)
inout(T)
get
()
(
scope const(char)[] key
,
lazy inout(T) defaultValue
)
if (
isMutable!T &&
!__traits(hasMember, T, "opPostMove")
&&
__traits(isUnsigned, U)
)

Examples

StringMap!int map;
map["c"] = 3;
assert(map.get("c", 1) == 3);
assert(map.get("C", 1) == 1);

Meta