Hashtable.insert

Insert the (key, value) pairs of an associative array into the hashtable.

If no allocator was provided when the list was created, the GCAllocator.std.experimental.allocator.gc_allocator. will be used.

struct Hashtable(K, V)
size_t
insert
(
U
)
if (
is(U == Value[Key],
Value : V
Key : K
)
)

Parameters

assocArr U

an associative array

Complexity: O(m), where m is the number of (key, value) pairs in the associative array.

Examples

import std.algorithm.comparison : equal;

auto h = Hashtable!(int, int)();
assert(h.length == 0);
h.insert([1 : 10]);
assert(equal(h.keys(), [1]));
assert(equal(h.values(), [10]));

Meta