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 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!postnews.google.com!t38g2000prd.googlegroups.com!not-for-mail From: Matthew Heaney Newsgroups: comp.lang.ada Subject: Re: Ada.Containers.Indefinite_Hashed_Maps Date: 26 Apr 2007 08:52:09 -0700 Organization: http://groups.google.com Message-ID: <1177602729.518278.188530@t38g2000prd.googlegroups.com> References: <1177510391.733055.133060@n35g2000prd.googlegroups.com> NNTP-Posting-Host: 66.162.65.129 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1177602736 20589 127.0.0.1 (26 Apr 2007 15:52:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 26 Apr 2007 15:52:16 +0000 (UTC) In-Reply-To: <1177510391.733055.133060@n35g2000prd.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: t38g2000prd.googlegroups.com; posting-host=66.162.65.129; posting-account=Zl1UPAwAAADEsUSm1PMMiDjihtBlZUi_ Xref: g2news1.google.com comp.lang.ada:15310 Date: 2007-04-26T08:52:09-07:00 List-Id: On Apr 25, 10:13 am, markp 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).