comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier <gautier@fakeaddress.nil>
Subject: Re: Dynamic allocation of named arrays
Date: Tue, 29 Apr 2008 22:59:23 +0200
Date: 2008-04-29T22:59:23+02:00	[thread overview]
Message-ID: <48178c1e_3@news.bluewin.ch> (raw)
In-Reply-To: <48178189$1_3@news.bluewin.ch>

Mmmmh - always better to test examples before posting...
This one is working:

-----8<-----------8<-----------8<-----------8<------

with Ada.Containers.Hashed_Maps;
with Ada.Strings.Unbounded.Hash;
with Ada.Text_IO;

procedure Dummy_dico is

   package Dictionaries is new Ada.Containers.Hashed_Maps
             (Ada.Strings.Unbounded.Unbounded_String,
              Ada.Strings.Unbounded.Unbounded_String,
              Ada.Strings.Unbounded.Hash,
              Ada.Strings.Unbounded."=",
              Ada.Strings.Unbounded."=");

   use Dictionaries;

   function "-" (Source : Ada.Strings.Unbounded.Unbounded_String) return String
     renames Ada.Strings.Unbounded.To_String;
   function "+" (Source : String) return Ada.Strings.Unbounded.Unbounded_String
     renames Ada.Strings.Unbounded.To_Unbounded_String;

   procedure Translate( dico: Map; from: String ) is
     use Ada.Text_IO;
   begin
     Put_Line( from & " ---> " & (-Element(dico,+from)) );
   end Translate;

   dico_F_to_E: Map;
   c: Cursor;
   s: Boolean;

begin
   Insert(dico_F_to_E, +"souris", +"mouse", c, s);
   Insert(dico_F_to_E, +"chat",   +"cat",   c, s);
   Insert(dico_F_to_E, +"chien",  +"dog",   c, s);
   Insert(dico_F_to_E, +"cheval", +"horse", c, s);
   --
   Translate(dico_F_to_E, "chien");
   Translate(dico_F_to_E, "chat");
end;



      reply	other threads:[~2008-04-29 20:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-29  9:12 Dynamic allocation of named arrays Kim Rostgaard Christensen
2008-04-29  9:55 ` Thomas Locke
2008-04-29 18:37   ` DScott
2008-04-29 19:38 ` Simon Wright
2008-04-29 20:14 ` Gautier
2008-04-29 20:59   ` Gautier [this message]
replies disabled

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