Map

Swiss tables hash map

Members

Aliases

SlotType
alias SlotType = Tuple!(K, "key", V, "value")
Undocumented in source.

Functions

byKey
Range!(IterMode.Key) byKey()
byKeyValue
Range!(IterMode.Both) byKeyValue()
byValue
Range!(IterMode.Value) byValue()
opApply
int opApply(int delegate(const ref K, ref V) dg)

foreach support

opBinaryRight
inout(V)* opBinaryRight(K key)

key in map syntax support.

opIndex
V opIndex(K key)

mapkey syntax support.

opIndex
inout(V) opIndex(K key)
Undocumented in source. Be warned that the author may not have intended to support it.
opIndexAssign
void opIndexAssign(V value, K key)

mapkey = value syntax support.

remove
bool remove(K key)

Remove key from the map.

Manifest constants

CompCondition
enum CompCondition;
Undocumented in source.
HashKeyArg
enum HashKeyArg;
Undocumented in source.

Mixins

__anonymous
mixin Table!(Map, K, SlotType, Allocator, hasIndirections!K || hasIndirections!V)
Undocumented in source.

Properties

keys
K[] keys [@property getter]
values
V[] values [@property getter]

Mixed In Members

From mixin Table!(Map, K, SlotType, Allocator, hasIndirections!K || hasIndirections!V)

HeapAlignment
enum HeapAlignment;
Undocumented in source.
this
this()
Undocumented in source.
this
this(Allocator allocator)

Constructor with the Allocator.

this
this(Allocator allocator, size_t capacity)

Constructor taking an initial capacity and the Allocator. Given capacity is automatically normalized to proper value.

this
this(size_t capacity)

Constructor taking an initial capacity. Given capacity is automatically normalized to proper value.

~this
~this()
Undocumented in source.
length
size_t length [@property getter]
capacity
size_t capacity [@property getter]
hashSeed
size_t hashSeed [@property setter]

Setter for hash seed.

dup
Container dup()
rehash
void rehash(size_t cap)

Reorganizes the container in place.

clear
void clear(bool reuse)

Removes all remaining slots from a container.

Parameters

K

key type

V

value type

Allocator

Allocator type to use internal allocation. Default is "shared const Mallocator"

initSlotInIndex

Assign V.init instead of RangeError when key not found. Default is "true"

initSlotInIndex is used for ++map[key] use-cases.

NOTE: Map doesn't guarantee pointer stability. Range and returned pointers are invalidated after insert/rehash.

Examples

// Initialize Map with capacity
auto map = Map!(string, string)(10);  // Default capacity is 0
map["key"] = "value";
auto p = "key" in map;
if (p)
  *p = "new value";
writeln(map["key"]);  // Print "new value"

// Support AA properties
map.length;
map.clear;
map.rehash;
map.dup;
K[] keys = map.keys;
V[] values = map.values;
foreach (k; map.byKey()) {}
foreach (v; map.byValue()) {}
foreach (e; map.byKeyValue()) {}  // e has key and value properties

Meta