Hashtable.this

Constructs a qualified hashtable out of an associative array that will use the provided allocator object. For immutable objects, a RCISharedAllocator must be supplied.

  1. this(A allocator)
  2. this(U assocArr)
  3. this(A allocator, U assocArr)
    struct Hashtable(K, V)
    this
    (
    A
    U
    this Q
    )
    if (
    !is(Q == shared) &&
    (
    is(A == RCISharedAllocator) ||
    !is(Q == immutable)
    )
    &&
    (
    is(A == RCIAllocator) ||
    is(A == RCISharedAllocator)
    )
    &&
    is(U == Value[Key],
    Value : V
    Key : K
    )
    )

Parameters

allocator A
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;
import stdx.collections.array : Array;

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

{
    auto h = immutable Hashtable!(int, int)([1 : 10]);
    assert(equal(h.values(), Array!int([10])));
}

Meta