Class ADT.OrderedMapping (< IndexType, ValueType >)

Description

This class works pretty much as a mapping except the order of the indices is kept in the order they are added. This class works equivalent to the Map() class in Javascript.

Example
OrderedMapping m1 = OrderedMapping("foo", 1, "bar", 2);
m1->gazonk = 3;

foreach (m1; string key; int val) {
  write("# %s: %d\n", key, val);
}

/*
  output:
    # foo: 1
    # bar: 2
    # gazonk: 3
*/

m_delete(m1, "gazonk");

m1 += OrderedMapping("afoo", 3);

foreach (m1; string key; int val) {
  write("# %s: %d\n", key, val);
}

/*
  output:
    # foo: 1
    # bar: 2
    # afoo: 3
*/

Generic IndexType

__generic__ mixed IndexType = mixed

Description

Type for the indices of the mapping.


Generic ValueType

__generic__ mixed ValueType = mixed

Description

Type for the values of the mapping.


Method create

ADT.OrderedMapping ADT.OrderedMapping(IndexType|ValueType ... args)

Example
ADT.OrderedMapping m1 = ADT.OrderedMapping("key1", "val1",
                                           "key2", "val2");
Throws

An error is thrown if the number of arguments isn't even.

Parameter args

Odd arguments are the indices, even arguments the values. "index", "value", "index", "value", ...