Re: How to use associative arrays in Ada 2005?



Hi!

First: @Matt: Thank you for the pdf. It's really useful, but I couldn't
write you back because of the email filter.

And now, my next question: How to handle "hashes of hashes" in Ada?
Here's the code which should contain a package representing a hash of a
hash:

-- Here, the code begins
with Ada.Text_IO,
Ada.Strings.Hash,
Ada.Containers.Indefinite_Hashed_Maps;
use Ada.Text_IO,
Ada.Strings,
Ada.Containers;

procedure book is
package Str_Int_Maps is
new Ada.Containers.Indefinite_Hashed_Maps
(String,
Integer,
Ada.Strings.Hash,
"=");
use Str_Int_Maps;
package Str_Map_Maps is
new Ada.Containers.Indefinite_Hashed_Maps
(String,
Str_Int_Maps.Map,
Ada.Strings.Hash,
"=");

Ages : Str_Map_Maps.Map; -- That's the "hash of a hash"

begin
Ages.Insert("family name",Insert("name",23));
end book;
-- Here, the code ends


The statement "Ages.Insert("family name",Insert("name",23));" doesn't
work. So, how is it possible to do something like this in C++:
"...
map<string, map<string,int>> ages;
ages["family name"]["name"] = 23;
...."

Thank you and greetings,
Matthias

.



Relevant Pages

  • Re: hask key
    ... I am collecting hash keys via http  request as string. ... "intern enters a symbol named string into package. ... You could also use a hash table that compares keys using equal (which ...
    (comp.lang.lisp)
  • Re: looking for some size optimization
    ... I end up with a hash of 250M. ... string for each item in a given package. ... I'll assume that actual conflicts are rare. ...
    (comp.lang.perl.misc)
  • Multiple Log Providers
    ... Logs the output from the package to custom tables. ... Dim strPathPkg As String ... Dim pkgChild As New Package ... ByVal sourceName As String, ByVal sourceID As String, ByVal ...
    (microsoft.public.sqlserver.dts)
  • Re: (?{..}) and lexical scoping issues.
    ... > @_ is most definitely a package variable. ... > (You are counting how many substrings of each string are also substrings ... > all substrings of a string. ... it will be hard to beat with a Perl program. ...
    (comp.lang.perl.misc)
  • Faild to udate Distribution Point
    ... ~The Package Action is 2 and the Update Mask is 268435456. ... TreeRecurser failed at FindFirstFile ... ~Starting to new hash ... ~Used 0 out of 3 allowed processing threads. ...
    (microsoft.public.sms.swdist)