Associative arrays question

Derek Parnell derek at psych.ward
Mon Dec 31 01:49:02 PST 2007


On Mon, 31 Dec 2007 04:20:34 -0500, Robby wrote:

> It's probably quite simple, but for some reason I seem to be in a blank.
> 
> I'm trying to write an associative array where a enum is the key and a 
> array of classes is the value.
> 
> So given a simple example
> enum T {Zero,One,Two,Three,Four,Five}
> class L {}
> 
> How would I write the declaration for an associative array?
> 
> I thought it may be  L[T[]][] but it's clearly not, help?

I would have thought that 
   
   L[][T] myAA;

   myAA[One] = new L;

would be it.

An array of classes ... L[]

The key is an enum (T) ... [T]

But did you mean that each element in the AA is an array of classes? In
that case ...

   L[][][T] myAA;

   L[] classarray;

   classarray ~= new L;
   classarray ~= new L;
   classarray ~= new L;

   myAA[One] = classarray;

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell


More information about the Digitalmars-d-learn mailing list