Find if keys are in two dimensional associative array
BCS
none at anon.com
Sun Jan 17 15:28:22 PST 2010
Hello Michal,
> if one has double indexed aa, how to find that it contains value under
> keys 'a' and 123
>
> float[int][char] aa;
>
> aa['a'][123] = 4.56;
>
> I had to make following helper function. Is there more elegant way /
> built in into D?
>
> float* isIn = doubleIn(123, 'a');
>
> float* doubleIn (int i, char ch) {
>
> float[int]* first = ch in aa;
>
> if (first is null)
> return null;
> else
> return i in *first;
> }
That's how I'd do it, more or less. However I'd skip the function (or go
with the more general case as shown by Simen).
float* isIn = null;
if(auto a = 'a' in aa) b = 123 in *a;
More information about the Digitalmars-d-learn
mailing list