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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4d2a71c8801ecab1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-06 03:29:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!demon!newspeer1-gui.server.ntli.net!ntli.net!newsfep2-win.server.ntli.net.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: <3D25E607.E59E11E2@acm.org> <3D26473B.581C61BC@acm.org> Subject: Re: Common sense... X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Sat, 6 Jul 2002 11:28:33 +0100 NNTP-Posting-Host: 80.5.140.234 X-Complaints-To: abuse@ntlworld.com X-Trace: newsfep2-win.server.ntli.net 1025951352 80.5.140.234 (Sat, 06 Jul 2002 11:29:12 BST) NNTP-Posting-Date: Sat, 06 Jul 2002 11:29:12 BST Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:26899 Date: 2002-07-06T11:28:33+01:00 List-Id: "Jeffrey Carter" wrote in message news:3D26473B.581C61BC@acm.org... > "chris.danx" wrote: > > > > "Jeffrey Carter" wrote in message > > news:3D25E607.E59E11E2@acm.org... > > > Deleting nodes from an iterator is erroneous and should raise an > > > exception. > > > > ok but how would you enforce that. Just not support it? That's no bother > > as the iterators aren't written yet. > > The PragmAda Reusable Components' list components' iterators will raise > an exception (Invalid_Position) if the client-supplied action deletes > the current node. This is a consequence of assigning a unique ID to each > list, marking each Position and node with the ID of the associated list, > and invalidating the ID when a node is deleted. That is similar to the method the list package uses. Each list is assigned an ID, each position within the list has that ID, and an exception is generated if the ID assigned to the position and the ID of the list don't match. This ensures consistancy on removal of nodes. Additionally, each node in the list holds a count of the number of iterators and the number of objects which point to it (called positions as they represent a position in a list). When both counts go to zero can a node be deallocated. If a call to remove/delete is placed on a node, and the count of either is not zero, the node is marked and skipped by the appropriate subprograms (next, previous, has_next, has_previous, head, last). I have my doubts as to whether this will be useful, some ops will be O(1) in best case and O(n) in worst, when they would usually be O(1) in best, average, and worst cases. Perhaps it would be better to raise an exception if a node held by an iterator is deallocated. Alternatively, the node could be marked but not deallocated until the counts both go to zero; with the effect that any position which holds So many choices, arghhhhhh!