Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Dynamic all...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 5674 of 5827
Post > Topic >>

Re: Dynamic allocation of named arrays

by Gautier <gautier@[EMAIL PROTECTED] > Apr 29, 2008 at 10:59 PM

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;
 




 6 Posts in Topic:
Dynamic allocation of named arrays
Kim Rostgaard Christensen  2008-04-29 11:12:17 
Re: Dynamic allocation of named arrays
Thomas Locke <thomas@[  2008-04-29 11:55:04 
Re: Dynamic allocation of named arrays
DScott <Merlin43PhD@[E  2008-04-29 13:37:12 
Re: Dynamic allocation of named arrays
Simon Wright <simon.j.  2008-04-29 20:38:01 
Re: Dynamic allocation of named arrays
Gautier <gautier@[EMAI  2008-04-29 22:14:15 
Re: Dynamic allocation of named arrays
Gautier <gautier@[EMAI  2008-04-29 22:59:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:06:49 CDT 2008.