From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Map iteration and modification Date: Thu, 28 Dec 2023 17:06:20 +0100 Organization: A noiseless patient Spider 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 16:06:20 -0000 (UTC) Injection-Info: dont-email.me; posting-host="5f5a904f70e875604898357a1c1025d4"; logging-data="468524"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+6jbTyajd7/aUdYxv34Fj4cJbxVBwv18=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:ZXACGNQupSc3Y2Qet4XhCDWaGmk= In-Reply-To: Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:65935 List-Id: 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] 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. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de