The OpenD Programming Language

StringMap.findPos

Finds position of the key in the associative array .

Return: An index starting from 0 that corresponds to the key or -1 if the associative array doesn't contain the key.

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

struct StringMap(T)
@trusted pure nothrow @nogc const
ptrdiff_t
findPos
()
(
scope const(char)[] key
)

Examples

StringMap!double map;
map["c"] = 3.0;
map["La"] = 4.0;
map["a"] = 5.0;

assert(map.findPos("C") == -1);
assert(map.findPos("c") == 0);
assert(map.findPos("La") == 1);
assert(map.findPos("a") == 2);

map.remove("c");

assert(map.findPos("c") == -1);
assert(map.findPos("La") == 0);
assert(map.findPos("a") == 1);

Meta