HashTable.this - multiple declarations
Function HashTable.this
Constructor.
this
(
size_t n,
shared Allocator allocator = defaultAllocator
);
this
(
shared Allocator allocator
);
Parameters
Name | Description |
---|---|
n | Minimum number of buckets. |
allocator | Allocator. |
Precondition
allocator !is null
.
Example
auto hashTable = HashTable!(string, int)(5);
assert(hashTable .capacity == 7);
Function HashTable.this
Initializes this HashTable from another one.
this(S)
(
ref S init,
shared Allocator allocator = defaultAllocator
)
if (is(Unqual!S == HashTable));
this(S)
(
S init,
shared Allocator allocator = defaultAllocator
)
if (is(S == HashTable));
If init is passed by reference, it will be copied. If init is passed by value, it will be moved.
Parameters
Name | Description |
---|---|
S | Source set type. |
init | Source set. |
allocator | Allocator. |
Precondition
allocator !is null
.
Function HashTable.this
Constructs the hash table from a forward range.
this(R)
(
scope R range,
shared Allocator allocator = defaultAllocator
)
if (isForwardRange!R && is(ElementType!R == KeyValue) && !isInfinite!R);
Parameters
Name | Description |
---|---|
R | Range type. |
range | Forward range. |
allocator | Allocator. |
Precondition
allocator !is null
.
Example
alias KeyValue = HashTable!(string, int) .KeyValue;
KeyValue[2] range = [KeyValue("one", 1), KeyValue("two", 2)];
auto hashTable = HashTable!(string, int)(range[]);
assert(hashTable["one"] == 1);
assert(hashTable["two"] == 2);
Function HashTable.this
Initializes the hash table from a static array.
Parameters
Name | Description |
---|---|
n | Array size. |
array | Static array. |
allocator | Allocator. |
Precondition
allocator !is null
.
Example
alias KeyValue = HashTable!(string, int) .KeyValue;
auto hashTable = HashTable!(string, int)([KeyValue("one", 1), KeyValue("two", 2)]);
assert(hashTable["one"] == 1);
assert(hashTable["two"] == 2);