From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9f842cdf16abf4b9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada.Containers.Indefinite_Hashed_Maps References: <1177510391.733055.133060@n35g2000prd.googlegroups.com> In-Reply-To: <1177510391.733055.133060@n35g2000prd.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1177523024 12.201.97.213 (Wed, 25 Apr 2007 17:43:44 GMT) NNTP-Posting-Date: Wed, 25 Apr 2007 17:43:44 GMT Organization: AT&T ASP.att.net Date: Wed, 25 Apr 2007 17:43:44 GMT Xref: g2news1.google.com comp.lang.ada:15287 Date: 2007-04-25T17:43:44+00:00 List-Id: markp wrote: > I am using a hash table via Ada.Containers.Indefinite_Hashed_Maps to > hash an array of records. We have a predfined array of records called > X. The insert function works fine by passing in X(1), X(2), etc. I am > having trouble with the syntax of the Update call, specifically the > Process parameter. Could somebody provide a quick snippet of code that > show how to setup this code and how the procedure actually looks to > update the data? There is no update; I presume you mean Update_Element. Given a map: package Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => Key_Value, Element_Type => Integer, ...); procedure Process (Key : in Key_Value; Item : in out Integer) is -- null; begin -- Process if Some_Quality (Key) then Item := Item + 1; end if; end Process; Map : Maps.Map; Some_Key : Key_Value; Position : Maps.Cursor; -- Put some values in Map. Some_Key := Get; if Maps.Contains (Map, Some_Key) then Position := Maps.Find (Map, Key => Some_Key); Maps.Update_Element (Container => Map, Position => Position, Process => Process'access); end if; If you've put a value in Map for the key with the value in Some_Key, and Some_Quality (Some_Key) returns True, then this will increment the value associated with that key value. For this kind of situation, you'd probably use Element and Replace rather than Find and Update_Element. Update_Element is more useful when you've got a cursor without knowing the key value, and want to modify the corresponding element. -- Jeff Carter "Apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, the fresh water system, and public health, what have the Romans ever done for us?" Monty Python's Life of Brian 80