HashMap

This struct implements a hashmap type, much like the standard associative array type.

This map should be almost totally usable in @safe pure nothrow functions.

An empty map will be a valid object, and will not result in any allocations.

Constructors

this
this(size_t minimumSize)

Construct a hashmap reserving a minimum of :minimumSize: space for the bucket list. The actual space allocated may be some number larger than the requested size, but it will be enough to fit as many items as requested without another allocation.

Members

Functions

dup
HashMap!(K, V) dup()

Copy an existing map into a new mutable map.

get
V get(K key, lazy V2 def)

Get a value from the map, or return the given default value, which is lazy-evaluated.

get
inout(V) get(K key)

Get a value from the map, or return V.init if a value is not set for a given key.

opBinaryRight
inout(V)* opBinaryRight(K key)

Implement the 'in' operator for a map.

opCast
bool opCast()

Implement boolean conversion for a map.

opEquals
bool opEquals(ref const(HashMap!(K, V)) otherMap)
bool opEquals(const(HashMap!(K, V)) otherMap)

Test if two maps are equal.

opIndex
inout(V) opIndex(K key)

Retrieve a value from the map.

opIndexAssign
void opIndexAssign(V value, K key)

Set a value in the map.

remove
bool remove(K key)

Remove a entry from the map if it is set, given a key.

setDefault
V setDefault(K key, lazy V2 value)

Get or create a value from/in the map.

setDefault
V setDefault(K key)

Get or create a value from/in a hashmap.

Properties

empty
bool empty [@property getter]
length
size_t length [@property getter]

The length of the map.

Meta