Re: How to use associative arrays in Ada 2005?
- From: "snoopysalive" <matthias.kistler@xxxxxx>
- Date: 26 Nov 2006 11:05:54 -0800
Hi!
First, I want to thank all of you for your examples and ideas. But they
don't work, sorry! So, I took your ideas and am trying to implement an
own procedure creating "hashes" like I need them.
The problem is that I need maps of maps of maps ... It's logical that a
container is able to get another container as element and it's no
problem to instanciate these containers and then put them one into the
other.
In my example code I tried to create a table of family names, names
and their ages. Let's make it a little more complex and create another
first key called "nation":
Nation | Family Name | Name | Age*
----------|---------------|---------------------|------
German | Goethe | Johann Wolfgang | 60
| | Catharina Elisabeth | 80
| | Johann Caspar | 90
| Hesse | Hermann | 51
Japanese | Kusanagi | Motoko | 29
American | Ford | Henry | 45
| | Harrison | 41
Finnish | Torvalds | Linus | 35
----------|---------------|----------------------------
* All ages are fictional because I don't know the real
ages of these persons or they are dead or fictional
The problem: Every single key needs a separate container map. We need 1
first-level, 4 second-level and 5 third-level key maps.
First-level = 1x map of string-map
Second-level = 4x map of string-map
Third-level = 5x map of string-integer
It would be necessary to create every single map and to put them one
into the other all manually for transforming the given table into a
"hash". That's easy and possible but not flexible. When posting the
code of my impossible programme, I had the idea of "anonymous"
container maps contained in maps. Because of this I wrote
"Ages.Insert("family name", Insert("name", 23));".
Sadly, Matt's solution didn't work. The statement "Ages.Insert ("family
name", C, B);" brought a compilation error: "no selector 'Insert' for
private type "Ada.Containers.Indefinite_Hashed_Maps.Map" from instance
at line 16". I found out that no procedure "Insert(String, Cursor,
Boolean)" exists. But it exists a procedure "Insert(String,
Element_Type, Cursor, Boolean)".
So, I'm trying to combine Matt's and Georg's ideas now. I'll write a
line, if I'd be successfull. Otherwise, I'll also write a line. ;-)
Once more: Thank you all. I'm commencing to have an idea of Ada-syntax
and philosphy and that's more than my professors at universitiy could
give me.
Greetings,
Matthias
.
- Follow-Ups:
- Re: How to use associative arrays in Ada 2005?
- From: Simon Wright
- 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?
- 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
- How to use associative arrays in Ada 2005?
- Prev by Date: Re: C to Ada
- Next by Date: Re: How to use associative arrays in Ada 2005?
- 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
|