ModelMap

ModelMap serves as an abstraction layer around associative arrays that store models. Usually ModelMaps will be a direct mapping of ID (Snowflake) -> Model.

Members

Functions

each
auto each(void delegate(TValue) f)

Allows applying a delegate over the values of the mapping

filter
auto filter(bool delegate(TKey, TValue) f)

Allows using a delegate to filter the keys/values of the mapping into a new mapping.

filter
auto filter(bool delegate(TValue) f)

Allows using a delegate to filter the values of the mapping

get
TValue get(TKey key)

Return the value for a key. Throws an exception if the key does not exist

get
TValue get(TKey key, TValue def)

Return the value for a key, or if it doesn't exist a specified default value

has
bool has(TKey key)

Returns true if the key exists within the mapping

keyUnion
TKey[] keyUnion(TKey[] other)

Return the set-union for an array of keys

keys
auto keys()

Returns an array of keys from the mapping

length
size_t length()

Returns the length of the mapping

opApply
int opApply(int delegate(ref TKey, ref TValue) dg)

Allows applying an operation as a delegate to the ModelMap

opIndex
TValue opIndex(TKey key)

Indexing by key

opIndexAssign
void opIndexAssign(TValue value, TKey key)

Indexing assignment

pick
TValue pick(bool delegate(TValue) f, TValue def)

Returns a single value from the mapping, based on the return value of a delegate

remove
void remove(TKey key)

Removes a key.

set
TValue set(TKey key, TValue value)

Set the key to a value.

subset
auto subset(TKey[] keysWanted)

Returns a new mapping from a subset of keys

values
auto values()

Returns an array of values from the mapping

Static functions

fromJSONArray
ModelMap!(TKey, TValue) fromJSONArray(IModel model, VibeJSON data)

Undocumented in source. Be warned that the author may not have intended to support it.

Variables

data
TValue[TKey] data;

Underlying associative array

Meta