From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Map iteration and modification Date: Thu, 28 Dec 2023 21:08:47 -0600 Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Fri, 29 Dec 2023 03:07:48 -0000 (UTC) Injection-Info: dont-email.me; posting-host="fc28b7e71a37236b148ceb2dd7a88638"; logging-data="761904"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BW2aQLLJZOlGxixkq88RTWI8/wxTFyOM=" Cancel-Lock: sha1:ybCOePuFB0jJkhYXmqjkVbmKJcI= X-MSMail-Priority: Normal X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 Xref: news.eternal-september.org comp.lang.ada:65938 List-Id: "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; Randy.