Re: Use .get() in MultiD Assoc Array?

2012-09-06 Thread Paul
On Saturday, 1 September 2012 at 05:23:35 UTC, Ali Çehreli wrote: On 08/31/2012 11:55 AM, Ali Çehreli wrote: > class MyTable [...] > // Enables the 'auto element = myIndex in myTable' syntax That's wrong. For that syntax to work, the operator below should have been opBinaryRight. > string

Re: Use .get() in MultiD Assoc Array?

2012-08-31 Thread Ali Çehreli
On 08/31/2012 11:55 AM, Ali Çehreli wrote: > class MyTable [...] > // Enables the 'auto element = myIndex in myTable' syntax That's wrong. For that syntax to work, the operator below should have been opBinaryRight. > string * opBinary(string op)(Index index) Yeah, that should have been opB

Re: Use .get() in MultiD Assoc Array?

2012-08-31 Thread Ali Çehreli
On 08/31/2012 08:56 AM, Paul wrote: >> You're welcome. Note that your need of having a structure which is >> both associative and ordered is, if not unheard-of, at least somewhat >> uncommon. > > I'm parsing program blocks from a proprietary HW/SW system. They provide > the data in the form of: >

Re: Use .get() in MultiD Assoc Array?

2012-08-31 Thread Philippe Sigaud
On Fri, Aug 31, 2012 at 5:56 PM, Paul wrote: > The data is in an ascii text file. > I need to be able to search it by group/block/parameter. > I need to be able to maintain group/block order. > There are ~hundred diff block types where the params and order of params are > known...though I would r

Re: Use .get() in MultiD Assoc Array?

2012-08-31 Thread Paul
You're welcome. Note that your need of having a structure which is both associative and ordered is, if not unheard-of, at least somewhat uncommon. I'm parsing program blocks from a proprietary HW/SW system. They provide the data in the form of: Somegroupname/Someblockname someparam=valu

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Philippe Sigaud
On Thu, Aug 30, 2012 at 10:24 PM, Paul wrote: > > So one array like- aa[MyKey("abc","def","ghi")] = "my value"; > > and another like- string[] da; da[99]="abc"~","~"def"~","~"ghi"; > or maybe- MyKey[] da; da[99]=MyKey("abc","def","ghi"); The latter, if you group your keys, I think. You

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Paul
On Thursday, 30 August 2012 at 19:40:44 UTC, Philippe Sigaud wrote: On Thu, Aug 30, 2012 at 9:30 PM, Jonathan M Davis wrote: Yes, that's what I wanted to propose. Group an AA and a standard, dynamic, array. The array is just filled with the key, when you assign a new key/value pair. To query

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Jonathan M Davis
On Thursday, August 30, 2012 21:40:34 Philippe Sigaud wrote: > On Thu, Aug 30, 2012 at 9:30 PM, Jonathan M Davis wrote: > > I believe that if you want a map (be it ordered or unordered) to give you > > items back in the order that you inserted them, then a separate list is > > required (be it int

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Philippe Sigaud
On Thu, Aug 30, 2012 at 9:30 PM, Jonathan M Davis wrote: > I believe that if you want a map (be it ordered or unordered) to give you > items back in the order that you inserted them, then a separate list is > required (be it integrated into the container or something you do alongside > it) where

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Philippe Sigaud
On Thu, Aug 30, 2012 at 8:57 PM, Paul wrote: > Maybe I'm not going about my project from the best angle? Another problem I > have is when I go to printout my array, being associative, it is not in the > order I built it. It would help greatly if I could print it in order. Associative arrays re

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Jonathan M Davis
On Thursday, August 30, 2012 20:57:44 Paul wrote: > Maybe I'm not going about my project from the best angle? > Another problem I have is when I go to printout my array, being > associative, it is not in the order I built it. It would help > greatly if I could print it in order. Hash tables (and a

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Paul
On Thursday, 30 August 2012 at 18:29:28 UTC, Paul wrote: On Thursday, 30 August 2012 at 18:20:02 UTC, Philippe Sigaud wrote: On Thu, Aug 30, 2012 at 7:18 PM, Paul wrote: From the book a way to respond to a non-existent key in an assoc. array: assert(aa["hello"] == "ciao"); // Key "hello" exi

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Paul
On Thursday, 30 August 2012 at 18:20:02 UTC, Philippe Sigaud wrote: On Thu, Aug 30, 2012 at 7:18 PM, Paul wrote: From the book a way to respond to a non-existent key in an assoc. array: assert(aa["hello"] == "ciao"); // Key "hello" exists, therefore ignore the second argume assert(aa.get("hel

Re: Use .get() in MultiD Assoc Array?

2012-08-30 Thread Philippe Sigaud
On Thu, Aug 30, 2012 at 7:18 PM, Paul wrote: > From the book a way to respond to a non-existent key in an assoc. array: > > assert(aa["hello"] == "ciao"); > // Key "hello" exists, therefore ignore the second argume > assert(aa.get("hello", "salute") == "ciao"); > // Key "yo" doesn’t exist, return

Use .get() in MultiD Assoc Array?

2012-08-30 Thread Paul
From the book a way to respond to a non-existent key in an assoc. array: assert(aa["hello"] == "ciao"); // Key "hello" exists, therefore ignore the second argume assert(aa.get("hello", "salute") == "ciao"); // Key "yo" doesn’t exist, return the second argument assert(aa.get("yo", "buongiorno") =