Associative array of dynamic array
Philippe Sigaud
philippe.sigaud at gmail.com
Sun Sep 9 05:27:58 PDT 2012
On Sun, Sep 9, 2012 at 2:18 PM, Samuele Carcagno <sam.carcagno at gmail.com> wrote:
> I would like to create an associative array that maps a string to a
> multidimensional dynamic array. In other words, I would like a data
> structure where I can access elements like this:
>
> foo["key"][0][0]
The type you want is int[][][string]. You can use it like this:
alias int[][][string] MyArray;
void main()
{
MyArray foo;
foo["abc"] = [[0,1,2], [3,4], []];
foo["def"] = [[0]];
assert(foo["abc"][0][1] == 1);
}
More information about the Digitalmars-d-learn
mailing list