From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!paganini.bofh.team!pasdenom.info!.POSTED.2a01:e0a:472:70f0:489f:9b4f:758a:47b3!not-for-mail From: DrPi <314@drpi.fr> Newsgroups: comp.lang.ada Subject: Re: Map iteration and modification Date: Thu, 28 Dec 2023 18:57:32 +0100 Organization: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 28 Dec 2023 17:57:33 -0000 (UTC) Injection-Info: rasp.pasdenom.info; posting-account="314@usenet"; posting-host="2a01:e0a:472:70f0:489f:9b4f:758a:47b3"; logging-data="5424"; mail-complaints-to="abuse@pasdenom.info" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:PAoutSDeupJPI+cl0LcaLLOW0Ec= sha256:KvdJ/gLmwA8/RWeIL+myo9cAmDXTRW3YywjbbtEB3E4= sha1:4J6vPWRv079i/WEohrH0GYLgdBY= sha256:TLiOJDMXxOfF3EPIL7dHH/FoLm8Ellr8SnTrThRxowA= Content-Language: fr In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:65936 List-Id: Le 28/12/2023 à 17:06, Dmitry A. Kazakov a écrit : > On 2023-12-28 14:59, DrPi wrote: >> 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 ? > > [Disclaimer. I am not talking about the standard library] I'm using the standard library ;) > > Provided a sane implementation of map. > > 1. It is safe to loop over the map items in the *reverse* order of, > deleting whatever items. > > 2. It is safe to walk whatever set of map keys, deleting items of the map. > > In both cases #1 positions, #2 keys are invariant to the operation of > deletion. >