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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,71c743c03ed191fe X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-20 07:53:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.visi.com!hermes.visi.com!uunet!ash.uu.net!spool0902.news.uu.net!not-for-mail Date: Fri, 20 Sep 2002 10:55:11 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Beginer problem: variable array size References: <38993b18.0209191906.b56b982@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1032533590.712308@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1032533591 16331 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:29222 Date: 2002-09-20T10:55:11-04:00 List-Id: Larry Kilgallen wrote: > Does C++ also have a built-in Sort primitive ? C++ has sorting algorithms as part of its standard library. It's got a regular sort, a stable sort, a partial sort, and a couple of related things. They're all written as templates, so the compare and swap portions can be inlined, giving much better performance than the old C qsort which uses a pointer to function to do comparisons. I think I'm becoming more used to Ada :-) When I saw the problem posed by the OP, I immediately thought of using a recursive function that built up and returned arrays, similar to what tmoran posted. MDC wrote: > The reality is that by putting a requirement out there > that there must be no limit on the number of elements > accepted, you create a difficulty that doesn't normally > exist in the real world. I've talked about this before. Until the GNU people came along and rewrote the UNIX text utilities, they would constantly and inconsistently return wrong results because of arbitrary limits, such as maximum line sizes. To this day, I cannot use vi on a Sun in an xterm that is "too wide". I have had text files with lines that were longer than 100000 characters which I needed to process. Wiring arbitrary limits into a program because you think that they are large enough for all uses is a recipe for disaster.