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.
items
deprecated alias items = toAA

Convert to D associative array

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

addNew
bool addNew(K key, V value)
Undocumented in source. Be warned that the author may not have intended to support it.
addNew
bool addNew(K key)
Undocumented in source. Be warned that the author may not have intended to support it.
at
inout(K) at(size_t i)

Index access (for ordered collections). For maps, returns the key.

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.

byRef
auto byRef()

Returns an object that allows iterating over this collection with ref keys. Workaround for https://issues.dlang.org/show_bug.cgi?id=21683

byRef
auto byRef()
Undocumented in source. Be warned that the author may not have intended to support it.
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
IV get(KK k, IV defaultValue)
Undocumented in source. Be warned that the author may not have intended to support it.
get
IV get(KK k, IV defaultValue)
Undocumented in source. Be warned that the author may not have intended to support it.
getAt
inout(K) getAt(size_t i, K defaultValue)

Index access (for ordered collections). For maps, returns the key.

indexOf
sizediff_t indexOf(K k)

Returns index of key k.

indicesOf
inout(size_t)[] indicesOf(K k)

Returns all indices of key k.

length
size_t length()

Total number of items, including with duplicate keys.

opApply
int opApply(int delegate(ref V) dg)

Iterate over values (maps).

opApply
int opApply(int delegate(const ref V) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(KeyIterationType!(false, false)) dg)

Iterate over keys (sets).

opApply
int opApply(int delegate(KeyIterationType!(true, false)) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref KeyIterationType!(false, true)) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref KeyIterationType!(true, true)) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(KeyIterationType!(false, false), ref V) dg)

Iterate over keys and values.

opApply
int opApply(int delegate(KeyIterationType!(true, false), const ref V) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref KeyIterationType!(false, true), ref V) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref KeyIterationType!(true, true), const ref V) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opAssign
typeof(this) opAssign(typeof(null) _)

Null assignment

opAssign
typeof(this) opAssign(AA aa)

Convert from an associative type

opAssign
typeof(this) opAssign(AA aa)

Convert from an associative type of multiple items

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)*, 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(AV v, AK 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(AV v, AK 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(AK 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(AK key)

Removes all elements with the given key.

require
V require(K key, V value)

Add value only if key is not present.

requireIndex
size_t requireIndex(K key, ValueVarType value)
Undocumented in source. Be warned that the author may not have intended to support it.
toAA
const(LookupValue[K]) toAA()

Convert to D associative array

toAA
LookupValue[K] toAA()
Undocumented in source. Be warned that the author may not have intended to support it.
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]

Returns all keys as an array.

values
auto values [@property getter]

Returns all values as an array.

Templates

_addSetFunc
template _addSetFunc(AddMode mode)
Undocumented in source.

Meta