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-10 14:07:48 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3BEDA5A1.B42EF7B7@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: List container strawman 1.2 References: <3BECA3B7.5020702@telepath.com> <87668ivpw8.fsf@deneb.enyo.de> <87d72qfrtd.fsf@deneb.enyo.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 10 Nov 2001 22:07:56 GMT NNTP-Posting-Host: 209.86.204.165 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1005430076 209.86.204.165 (Sat, 10 Nov 2001 14:07:56 PST) NNTP-Posting-Date: Sat, 10 Nov 2001 14:07:56 PST Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Sat, 10 Nov 2001 14:03:45 PST (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:16250 Date: 2001-11-10T22:07:56+00:00 List-Id: Ted Dennison wrote: > > Assume: > package Integer_List is new Containers.Lists.Unbounded (Integer); > > Version 1: > procedure Sort_Increasing is new Integer_List.Sort (Reverse_Order => ">"); > > Version 2: > procedure Sort_Increasing is new Integer_List.Sort (In_Order => "<"); Or possibly Out_Of_Order instead of Reverse_Order, though I think "<" is clearer. > > I'm not sure what you mean by "Stable". If you mean some flag will be set and > every insertion after that will also call "Reverse_Order" to keep things sorted > that way, I'd say no. Hmmm. I'd meant to add an "Insert_Sorted" routine for that > issue. Perhaps you were leading up to that. A stable sort keeps identical values in the same order after the sort. An unstable sort may change the order of identical values. Consider sorting something like 1(1), 1(2), 1(3), 1(4) [where 1(n) indicates that this instance of 1 occurs nth in the unsorted list] into ascending order. If 1(I) always occurs before 1(I+1) in the sorted list then the sort is stable. In many cases this is irrelevant. For example, a well optimized quick sort is faster than other sorts for large sets in almost all situations, but is unstable. However, it is an easy matter to include a position number with each value and define "<" so it sorts identical values into the correct order, thus gaining the speed of quick sort without sacrificing stability. Merge sort seems to be the best sort for a list. Although it's O(N) in space, that extra space already exists in a list as the pointers between nodes, so it becomes O(N) in space. Merge sort is always O(N log N) in time. -- Jeff Carter "Son of a window-dresser." Monty Python & the Holy Grail