HashCollection

Base type for ordered/unordered single-value/multi-value map/set

struct HashCollection (
K
V
bool ordered
bool multi
) {}

Constructors

this
this(Input input)

Construct from something else

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

add
alias add = addSetFunc!(AddMode.add)

Add an item.

getAll
deprecated alias getAll = valuesOf
Undocumented in source.
getOrAdd
deprecated alias getOrAdd = require
Undocumented in source.
set
alias set = addSetFunc!(AddMode.replace)

Ensure a key exists (with the given value). When multi==true, replaces all previous entries with this key. Otherwise, behaves identically to add.

Functions

byKey
auto byKey()

Return a range which iterates over all keys. Duplicate keys will occur several times in the range.

byKeyValue
auto byKeyValue()
byPair
auto byPair()

Return a range which iterates over key/value pairs.

byValue
auto byValue()

Return a range which iterates over all values.

byValueOf
auto byValueOf(K k)

Return a range with all values with the given key. If the key is not present, returns an empty range.

clear
void clear()

Removes all elements.

count
size_t count(K k)

Return the number of items with the given key. When multi==false, always returns 0 or 1.

dup
typeof(this) dup()

Create shallow copy

empty
bool empty()

True when there are no items.

get
inout(IV) get(IK k, inout(IV) defaultValue)

Retrieve last value associated with key, or defaultValue if none.

indexOf
size_t indexOf(K k)
Undocumented in source. Be warned that the author may not have intended to support it.
indicesOf
size_t[] indicesOf(K k)
Undocumented in source. Be warned that the author may not have intended to support it.
length
size_t length()

Total number of items, including with duplicate keys.

opApply
int opApply(int delegate(ref SingleIterationType x) dg)
int opApply(int delegate(const ref SingleIterationType x) dg)

Iterate over keys (sets) / values (maps).

opApply
int opApply(int delegate(K k, ref V v) dg)
int opApply(int delegate(K k, const ref V v) dg)

Iterate over keys and values.

opAssign
typeof(this) opAssign(typeof(null) _)

Null assignment

opAssign
typeof(this) opAssign(AA aa)

Convert from an associative type

opAssign
typeof(this) opAssign(R input)

Convert from a range of tuples

opAssign
typeof(this) opAssign(R input)

Convert from a range of key/value pairs

opAssign
typeof(this) opAssign(R input)

Convert from a range of values

opBinaryRight
Select!(haveReturnType, inout(ReturnType!void)*, bool) opBinaryRight(_K key)

Check if item with this key has been added. When applicable, return a pointer to the last value added with this key.

opCast
bool opCast()

Convert to bool (true if non-null)

opIndex
inout(IV) opIndex(IK k)

Index operator. The key must exist. Indexing with a key which does not exist is an error.

opIndexAssign
IV opIndexAssign(IV v, IK k)

Same as set(k, v).

opIndexAssign
IV opIndexAssign(IV v, IK k)

Allows writing to ordered sets by index. The total number of elements never changes as a result of such an operation - a consequence of which is that if multi==false, changing the value to one that's already in the set is an error.

opIndexOpAssign
IV opIndexOpAssign(IV v, IK k)

Perform cumulative operation with value (initialized with .init if the key does not exist).

opIndexOpAssign
IV opIndexOpAssign(VV v, IK k)

Perform cumulative operation with value at index.

opIndexUnary
IV opIndexUnary(IK k)

Perform unary operation with value (initialized with .init if the key does not exist).

opIndexUnary
IV opIndexUnary(IK k)

Perform unary operation with value at index.

remove
bool remove(K key)

Removes all elements with the given key.

require
V require(K key, V value)

Add value only if key is not present.

update
void update(K key, C create, U update)

If key is present, call update for every value; otherwise, add new value with create.

valuesOf
V[] valuesOf(K k)

Return an array with all values with the given key. If the key is not present, returns an empty array.

Properties

keys
auto keys [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
values
auto values [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Templates

addSetFunc
template addSetFunc(AddMode mode)
Undocumented in source.

Meta