LazedAssocArray

Lazed Associative Array

For instance; assocArray["key"] = new ValueType The above code create a new instance of ValueType with some consts(memory amount and time). However it likely to be a bobottleneck if the value isn't needed. Then this class provides lazed associative array, this class willn't create an instance until the value become needed. In other words, this is sort of lazy evaluation for performance.

Alias This

storage

Members

Functions

insert
void insert()

This function works like: // laa is an instance of LazedAssocArray laa["key"] = new T; with following way: laa.insert!("key", "new T");

link
void link(string alternative, string key)

Make an alias of the key

opIndex
T opIndex(string key)

An overloaded function of opIndex This function hooks: laa["key"] event.

opIndexAssing
T opIndexAssing(T value, string key)

An overloaded function of opIndexAssing This function hooks: laa["key"] = value; event but this function might be no use

set
void set(string key, T value)

Set the value with the key. This function works like: laa["key"] = value; with laa.set("key", value)

Variables

called
bool[string] called;

Flags, indicates whether the instance of the key is already created

constructors
T delegate()[string] constructors;

This variable holds the constructor calling delegate to make the instance which will be called when the isntance become needed.

storage
T[string] storage;

This variable holds the instance as a value of hashmap.

Meta