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,a644fa9cd1a3869a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-13 11:39:42 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!hub1.nntpserver.com!sjcppf01.usenetserver.com!usenetserver.com!news-west.rr.com!lsnws01.we.mediaone.net!typhoon.san.rr.com!not-for-mail Message-ID: <3BF17705.637A8B6E@san.rr.com> From: Darren New Organization: Boxes! X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: List container: Insert and Delete References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 13 Nov 2001 19:40:08 GMT NNTP-Posting-Host: 66.75.151.160 X-Complaints-To: abuse@rr.com X-Trace: typhoon.san.rr.com 1005680408 66.75.151.160 (Tue, 13 Nov 2001 11:40:08 PST) NNTP-Posting-Date: Tue, 13 Nov 2001 11:40:08 PST Xref: archiver1.google.com comp.lang.ada:16438 Date: 2001-11-13T19:40:08+00:00 List-Id: Steven Deller wrote: > > > -----Original Message----- > > From: comp.lang.ada-admin@ada.eu.org > > [mailto:comp.lang.ada-admin@ada.eu.org] On Behalf Of Darren New > > Sent: Tuesday, November 13, 2001 12:47 PM > > To: comp.lang.ada@ada.eu.org > > Subject: Re: List container: Insert and Delete > > > > > > Ted Dennison wrote: > > > Should we remove all basic-looking routines from either > > implementation > > > with time behavior >=O(N). > > > > Definitely not. All that will do is force people to recreate > > the functionality they need anyway, except without the > > benefit of being able to access the internal structures. > > > > For example, I strongly suggest that there be a mechanism to > > translate between positions and integer offsets and back. > > This is an O(N) operation, obviously, compared to the O(1) of > > moving the position. However, if someone has a list that they > > want to stuff out to a file, along with an offset (say, the > > one currently on the screen), they need a way to handle that. > > Denying the ability to translate between positions and > > integers just means that someone's going to write code full > > of things like > > offset := offset + 1; > > pos := Next(pos); > > I wouldn't object to a function > subtype position_index is natural ; > head_position : constant position_index := 0 ; > function offset (pos) return position_index ; > that returns the current index. > > Done right, this index can be maintained as part of "pos", even in the > face of insertions, and deletions. All in O(1) time. Good point. > I do object to making a List into a Map (and a Map limited to a > particular index type at that). > > Please don't add array indexing to lists. Then you need some way to map a "pos" onto something you can save, and something to map it back. For example, if you're implementing Streams, you'll need something like this anyway, yes? -- Darren New San Diego, CA, USA (PST). Cryptokeys on demand. You will soon read a generic fortune cookie.