From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.gegeweb.eu!gegeweb.org!pasdenom.info!.POSTED.famillepinault.fr!not-for-mail From: DrPi <314@drpi.fr> Newsgroups: comp.lang.ada Subject: Re: Map iteration and modification Date: Fri, 29 Dec 2023 14:53:53 +0100 Organization: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 29 Dec 2023 13:53:54 -0000 (UTC) Injection-Info: rasp.pasdenom.info; posting-account="314@usenet"; posting-host="famillepinault.fr:82.65.30.55"; logging-data="14532"; mail-complaints-to="abuse@pasdenom.info" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:rRpS2DQ2mwc0rjmkUyNZyHRk9JY= sha256:gy+i7qNo0rmBw4gr8fxDZucF8vu/f/zsDpBjtGvy4xo= sha1:2/iiQKjCpj4D0eqlgQ7lE/5BZ7Y= sha256:4BlA0MZykKvWvhmFML5OYTVyXiVKwQrIqXiY4Jeipdw= In-Reply-To: Content-Language: fr Xref: news.eternal-september.org comp.lang.ada:65941 List-Id: Le 29/12/2023 à 04:08, Randy Brukardt a écrit : > "DrPi" <314@drpi.fr> wrote in message > news:umjuvc$9sp$2@rasp.pasdenom.info... >> Le 28/12/2023 à 14:53, DrPi a écrit : >>> Iterate the Map and temporarily store the key nodes to be deleted then >>> delete the nodes from the key list ? >> >> Not clear. Rephrasing it. >> Using 2 steps by iterating the Map and temporarily store the keys of nodes >> to be deleted then delete the Map nodes using the key list ? > > If the keys are messy to save (as say with type String), it might be easier > to save the cursor(s) of the nodes to delete. You would probably want to use > a cursor iterator (that is, "in") to get the cursors. Code would be > something like (declarations of the Map and List not shown, nor is the > function Need_to_Delete which is obviously application specific, Save_List > is a list of cursors for My_Map, everything else is standard, not checked > for syntax errors): > > Save_List.Empty; -- Clear list of saved cursors. > -- Find the nodes of My_Map that we don't need. > for C in My_Map.Iterate loop > if Need_to_Delete (My_Map.Element(C)) then > Save_List.Append (C); > -- else no need to do anything. > end if; > end loop; > -- Delete the cursors of the nodes we don't want anymore. > for C of Save_List loop > My_Map.Delete(C); > end loop; > > That's what I did but I saved the keys (String) instead of the cursors. Does it make a difference ? Performance maybe ? Nicolas > > Randy. > >