From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Multiple keys for a map
Date: Tue, 17 Sep 2013 22:19:18 -0700 (PDT)
Date: 2013-09-17T22:19:18-07:00 [thread overview]
Message-ID: <58c932ec-9830-4ae2-8244-91d621d9d694@googlegroups.com> (raw)
In-Reply-To: <4f66d847-d030-4aa9-8bdf-9bcc5f3a0852@googlegroups.com>
On Tuesday, September 17, 2013 8:51:24 AM UTC-6, Peter Brooks wrote:
> I know that maps in Containers.Hashed_Maps and Containers.Ordered_Map are designed as single-key look-up tables.
>
> Is there an extension that allows multiple keys?
>
> I'd like to be able to do something like this:
>
> procedure Insert (Container : in out Map;
> key1, key2, key3 : in Key_Type;
> New_Item : in Element_Type;
> Position : out Cursor;
> Inserted : out Boolean);
>
> allowing:
>
> insert(my_map,"fox","jumps","dog","The quick brown fox jumps over the lazy dog",location,succeeded);
> insert(my_map,"cow","jumps","moon","The cow jumps over the moon",location,succeeded);
> insert(my_map,"dog","jumps","log","The lazy dog jumps over the small log",location,succeeded);
> insert(my_map,"dog","jumps","bed","The very lazy dog jumps into bed",location,succeeded)
>
> So that later, I can have:
> Subject := find(my_map,"fox",-,-);
> Verb := find(my_map,-,"jumps",-);
> Object := find(my_map,-,-,"dog");
>
> and, after this:
> Subject = Verb = Object;
>
> I know this could be done with three calls to Insert, but I also want to be able to call:
>
> find(mymap,"fox","jumps","dog") => true
> and
> find(mymap,"dog","jumps","fox") => false
> and, ideally,
> find(myman,"dog",-,-) =>
>
> "The Lazy dog jumps over the small log"
> "The very lazy dog jumps into bed"
>
> Any suggestions?
I'm vaguely reminded of Prolog by this question: this problem was basically the intro for the book I had.
next prev parent reply other threads:[~2013-09-18 5:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-17 14:51 Multiple keys for a map Peter Brooks
2013-09-17 16:52 ` Dmitry A. Kazakov
2013-09-17 17:49 ` Peter Brooks
2013-09-18 7:22 ` Dmitry A. Kazakov
2013-09-18 9:34 ` Peter Brooks
2013-09-17 18:57 ` gautier_niouzes
2013-09-17 19:20 ` Peter Brooks
2013-09-18 5:19 ` Shark8 [this message]
2013-09-18 5:44 ` Peter Brooks
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox