The OpenD Programming Language

HashMap.getOrAdd

If the given key does not exist in the HashMap, adds it with the value defaultValue.

struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K, bool supportGC = shouldAddGCRange!K || shouldAddGCRange!V, bool storeHash = true)
getOrAdd
(
this This
)
(
K key
,)

Parameters

key K

the key to look up

defaultValue V

the default value

Return Value

Type: auto

a pointer to the value stored in the HashMap with the given key. The pointer is guaranteed to be valid only until the next HashMap modification.

Meta