Re: How to use associative arrays in Ada 2005?
- From: Matthew Heaney <matthewjheaney@xxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 01:55:07 GMT
Simon Wright <simon@xxxxxxxxxxxx> 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.
.
- References:
- How to use associative arrays in Ada 2005?
- From: snoopysalive
- Re: How to use associative arrays in Ada 2005?
- From: Matthew Heaney
- Re: How to use associative arrays in Ada 2005?
- From: snoopysalive
- Re: How to use associative arrays in Ada 2005?
- From: snoopysalive
- Re: How to use associative arrays in Ada 2005?
- From: Dmitry A. Kazakov
- Re: How to use associative arrays in Ada 2005?
- From: Matthew Heaney
- Re: How to use associative arrays in Ada 2005?
- From: snoopysalive
- Re: How to use associative arrays in Ada 2005?
- From: Simon Wright
- Re: How to use associative arrays in Ada 2005?
- From: Matthew Heaney
- Re: How to use associative arrays in Ada 2005?
- From: Simon Wright
- How to use associative arrays in Ada 2005?
- Prev by Date: Re: Multitasking and containers
- Next by Date: Re: Multitasking and containers
- Previous by thread: Re: How to use associative arrays in Ada 2005?
- Next by thread: Re: How to use associative arrays in Ada 2005?
- Index(es):
Relevant Pages
|