Map.put

Looks up the mapping for key or adds one if not found.

Note that, if a new mapping was added (added outputs true), the returned slice may reference a previously removed value. If this is not desired, copy the desired initial value into the sliced buffer returned by remove().

  1. void[] put(K key, bool added)
    class Map(size_t V, K)
    void[]
    put
    (
    in K key
    ,
    out bool added
    )
    out (val) { assert (val.length == V); }
  2. void[] put(K key)

Parameters

key K

key to add/update mapping for

added bool

set to true if the record did not exist but was added

Return Value

Type: void[]

an array slicing the value buffer mapped to by the specified key. If added outputs true, the value is unspecified and the caller should set the value as desired.

Out: The returned array is never null and has the length V.

Meta