Initialize multi dimensional associative dynamic array
bearophile
bearophileHUGS at lycos.com
Sun Dec 2 09:23:20 PST 2012
(Maybe this will arrive duplicated, thanks to the forum software)
js.mdnq:
> myval1 = arr["Group1"][3243]; // has O(1) lookup
> myval2 = arr["Group2"][3243]; // has O(1) lookup
Another option is to use an associative array where the keys are
Tuple!(string, int):
alias Tuple!(string, int) Tkey;
int[Tkey] arr;
myval1 = arr[Tkey("Group1", 3243)];
myval2 = arr[Tkey("Group2", 3243)];
But also take this in account:
http://d.puremagic.com/issues/show_bug.cgi?id=3789
> But when I try to access the value of the value I get an
> exception, I believe, because I haven't initialized the value.
> (because if I do a simple assign to the value it then works,
> but I'm trying to check if the value exists in the first place)
Why don't you show what you are trying to do with a little
program, plus the errors you get?
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list