comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <mheaney@on2.com>
Subject: Re: Ada.Containers.Indefinite_Hashed_Maps
Date: 26 Apr 2007 08:52:09 -0700
Date: 2007-04-26T08:52:09-07:00	[thread overview]
Message-ID: <1177602729.518278.188530@t38g2000prd.googlegroups.com> (raw)
In-Reply-To: <1177510391.733055.133060@n35g2000prd.googlegroups.com>

On Apr 25, 10:13 am, markp <markwor...@yahoo.com> wrote:
> I am using a hash table via Ada.Containers.Indefinite_Hashed_Maps to
> hash an array of records.

What do you mean by "hash an array of records"?  Does the data live
inside an array, or inside a map?  What is the key type?  What is the
element type?


> We have a predfined array of records called
> X. The insert function works fine by passing in X(1), X(2), etc.

What is the map key type?

Are you inserting an array component value into the map?  Does this
mean the data is getting stored twice (first as an array element, and
again as a map element)?


> I am
> having trouble with the syntax of the Update call, specifically the
> Process parameter.

Update_Element works fine if you already have a cursor, and you want
to modify an element in-place.  Something like:

procedure My_Update (M : in out Map; C : Cursor) is
   procedure Process (K : KT; E : in out ET) is
   begin
      ... -- modify E as necessary
   end;
begin
   M.Update_Element (C);
end;

If you want to simply replace what's there (instead of modifying the
element in-place), then you can use Replace_Element:

M.Replace_Element (C, E);

If you don't have a cursor, then you can use Insert:

M.Insert (K, E);

Note that Insert will raise an exception if K is already in the map.

You could also use Replace:

M.Replace (K, E);

Note that Replace will raise an exception if K is not in the map.

You could also use Include:

M.Include (K. E);

Note that Include does not raise an exception.  If K is in the map,
then E will replace what's already there, and if K is not in the map,
then E will be inserted.

There is also a conditional form of Insert, that does not raise an
exception.  It reports back (with a status value) whether the key/
element pair was actually inserted ("successful" insertion depends on
whether the key was already in the map).




  parent reply	other threads:[~2007-04-26 15:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-25 14:13 Ada.Containers.Indefinite_Hashed_Maps markp
2007-04-25 17:43 ` Ada.Containers.Indefinite_Hashed_Maps Jeffrey R. Carter
2007-04-26 12:12   ` Ada.Containers.Indefinite_Hashed_Maps Maciej Sobczak
2007-04-26 12:55     ` Ada.Containers.Indefinite_Hashed_Maps Stefan Bellon
2007-04-26 16:13       ` Ada.Containers.Indefinite_Hashed_Maps Matthew Heaney
2007-04-27  4:39     ` Ada.Containers.Indefinite_Hashed_Maps Jeffrey R. Carter
2007-04-26 15:52 ` Matthew Heaney [this message]
2007-04-26 19:56   ` Ada.Containers.Indefinite_Hashed_Maps Matthew Heaney
2007-04-26 16:12 ` Ada.Containers.Indefinite_Hashed_Maps Matthew Heaney
replies disabled

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