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-Thread: 103376,f2690a5e963b61b6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: GCC 4.0 Ada.Containers Cursor danger. References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <42C98672.3020705@arcor.de> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 06 Jul 2005 12:41:32 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1120653692 24.149.57.125 (Wed, 06 Jul 2005 05:41:32 PDT) NNTP-Posting-Date: Wed, 06 Jul 2005 05:41:32 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:11896 Date: 2005-07-06T12:41:32+00:00 List-Id: Maxim Reznik writes: > If container knows all his cursors it can do it easy. No, a container does *not* "know all his cursors". It only has the storage it needs for elements. It certainly would be possible to implement a container abstraction this way: maintain a reference count for each node, to count how many extant cursors designate that node. When the element is deleted from the container, then check the reference count: if it's greater than 0, then move the element (really, it's internal storage node) onto a pending delete list. When a cursor attempts to dereference an element on the pending delete list, then raise an exception. This is all possible. But notice that it comes at a significant cost: there is additional per-element storage overhead, and the cursor type must be controlled.