MutexedAA.uniqueKey

Reserves a unique key in the associative array.

Note: The key type must be an integral type.

struct MutexedAA(AA : V[K], V, K)
static if(isIntegral!K)
uniqueKey
()
(
K min = 1
,
K max = K.max
,
V value = V.init
)

Parameters

min K

Optional minimum key value; defaults to 1`.

max K

Optional maximum key value; defaults to K.max, where K is the key type of the passed associative array.

value V

Optional value to assign to the key; defaults to V.init, where V is the value type of the passed associative array.

Return Value

Type: auto

A unique key for the passed associative array, for which there is now a value of value.`

Examples

MutexedAA!(string[int]) aa;
aa.setup();  // important!

int i = aa.uniqueKey;
assert(i > 0);
assert(aa.has(i));
assert(aa[i] == string.init);

See Also