comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: How to use associative arrays in Ada 2005?
Date: Tue, 28 Nov 2006 01:55:07 GMT
Date: 2006-11-28T01:55:07+00:00	[thread overview]
Message-ID: <uzmacqqru.fsf@earthlink.net> (raw)
In-Reply-To: m2irh0a445.fsf@grendel.local

Simon Wright <simon@pushface.org> writes:

> But that only works for the first map. You couldn't find all the
> Smiths that way.
> 
> If that's what you're after, you need (in database terms) a second
> independent index.

Right.  In the GNAT distribution there's an examples directory that includes
some container examples.  The library example does what you suggest, using
multiple containers to provide the necessary query support.


> I've just read (and re-read, and re-read) A.18.5(43) and I see what
> you mean. Perhaps it's a bit late. I had read 'same hash =>
> equivalent' whereas it's actually 'equivalent => same hash'.

Right.


> > If you have as your key a record comprising the 3 strings (nation,
> > family name, given name), then "=" would be adequate for
> > Equivalent_Keys.
> 
> I would have a record with (nation, family_name, given_name, age) --
> if you have filtered out a container with just the Smiths you'd want
> to know the other facts for each of them, too.

You could have the map of maps of maps (as in the OP), and use another
container (an ordered multiset, say) whose elements are cursors designating a
family-name/(given-name/age) map.  (Using cursors means you never have to
duplicate data.)  The cursors would be ordered according to family-name (that
is, by the key that the cursor points to).

Actually, there are probably many ways to do it.  During the design of the
container library, both the container and cursor types were declared as
definite and non-limited specifically to facilitate the kinds of composition as
in your example.  



  reply	other threads:[~2006-11-28  1:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-21 10:11 How to use associative arrays in Ada 2005? snoopysalive
2006-11-21 11:49 ` Georg Bauhaus
2006-11-21 14:18 ` Matthew Heaney
2006-11-21 23:35   ` snoopysalive
2006-11-23 19:27     ` snoopysalive
2006-11-23 19:40       ` Georg Bauhaus
2006-11-24  0:33       ` Georg Bauhaus
2006-11-24 11:49         ` Matthew Heaney
2006-11-24  8:27       ` Dmitry A. Kazakov
2006-11-24 11:51         ` Matthew Heaney
2006-11-26 19:05           ` snoopysalive
2006-11-26 20:30             ` Matthew Heaney
2006-11-27  9:15             ` Dmitry A. Kazakov
2006-11-27 19:53               ` Matthew Heaney
2006-11-27 21:11                 ` Dmitry A. Kazakov
2006-11-27 21:52                   ` Matthew Heaney
2006-11-28  8:29                     ` Alex R. Mosteo
2006-11-28 13:19                       ` Matthew Heaney
2006-11-28  8:34                     ` Dmitry A. Kazakov
2006-11-28 13:21                       ` Matthew Heaney
2006-11-27 21:08             ` Simon Wright
2006-11-27 22:22               ` Matthew Heaney
2006-11-27 22:58                 ` Simon Wright
2006-11-28  1:55                   ` Matthew Heaney [this message]
2006-11-24 11:35       ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox