struct OrderedMap(K, V)

A simple data structure based on the built-in associative array, but with a fixed element order.

OrderedMap dup() const

This method returns a copy of the map.

void put(K key, V value)

Inserts a key-value pair into the map.

V get(K key, lazy V defaultValue = V.init) const

Safely returns the value associated with the given key. If the key does not exist, returns defaultValue.

void remove(K key)

Removes an element by the specified key. Does nothing if the key is not present.

V[] values() const

Returns array of values.

size_t length() nothrow const

Returns the number of elements in the map.

string toString() const

Returns a string representation.

auto byKey()

Returns a range for iterating over the keys.

auto byValue()

Returns a range for iterating over the values.

auto byKeyValue()

Returns a range for iterating over the keys and the values.

private V[K] map

Underlying associative array for key-value storage.

private K[] keyArray

Array of keys preserving insertion order.

Variables

map

Underlying associative array for key-value storage.

keyArray

Array of keys preserving insertion order.

Methods

dup length
put toString
get byKey
remove byValue
values byKeyValue