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!news1.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread1.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> <1120575076.876798.108220@g44g2000cwa.googlegroups.com> <1120583470.429264.325450@g43g2000cwa.googlegroups.com> <42cb8d21$0$22761$9b4e6d93@newsread2.arcor-online.net> <42cd064c$0$10817$9b4e6d93@newsread4.arcor-online.net> 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: Thu, 07 Jul 2005 13:41:11 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.atl.earthlink.net 1120743671 24.149.57.125 (Thu, 07 Jul 2005 06:41:11 PDT) NNTP-Posting-Date: Thu, 07 Jul 2005 06:41:11 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:11933 Date: 2005-07-07T13:41:11+00:00 List-Id: "Dmitry A. Kazakov" writes: > Rather it does some element at another location. The element is of > little matter here (for this concrete case, note.) Otherwise "Replace" > would have no sense. BTW the parameters of the type Cursor are > routinely named "Position"! Part of the benefit of cursors is precisely that they abstract-away the container, and allow you to view the elements in the container simply as an abstract sequence, in which the elements are logically contiguous. That's the sense of "position" or "location" of an element. The benefit is that this model applies to all containers, which means you can write an algorithm in terms of cursors, that works for any container. Stepanov refers to this as the "machine model." In this model, you can think of elements as having an address. A cursor a like a pointer, in the sense that it designates an element at a particular address. You can navigate among addresses (Next, Previous, etc), and dereference the pointer (Element, Query_Element, Replace_Element, etc). Yes, it's a rather low-level view of a container, but that's why it's so flexible. (Of cousre, if this model doesn't suit you, then you don't have to use cursors, especially for a map.) Our philosophy during the design of the standard container library was to not reinvent the wheel, and so we borrowed heavily from the STL. In order to understand the design of the Ada standard container library, you really need to understand the design of the STL. There are lots of interviews with Alexander Stepanov on the WWW, as well as many STL tutorials.