comp.lang.ada
 help / color / mirror / Atom feed
From: uvaarpa!software.org!smithd@mcnc.org  (Doug Smith)
Subject: Re: c++ vs ada results
Date: 16 Aug 91 17:56:16 GMT	[thread overview]
Message-ID: <1991Aug16.175616.20103@software.org> (raw)

In article <1991Aug15.154021.24043@cats.com> andy@cats.com (Andy Davidson) writ
es:
> In article <1991Aug14.182554.16576@software.org> smithd@software.org (Doug Sm
ith) writes:
> >
> >It is possible to take an algorithmic approach to building these
> >utilities.  This creates a smaller library of generics that provide the

> What exactly do you mean by an "algorithmic approach"? Do you mean a
> structured design approch?? Can you elaborate on your statement
> 
(I don't think this is structured design, you be the judge...)

Since several people have asked for more information...

There is a published work that you can reference:

    The Ada Generic Library
        Linear List Processing Packages
    Musser & Stepanov
    Springer-Verlag 1989

An example that comes to mind is the usual sort generic:

    generic
        type Element is private;
        type Index is (<>);
        type Arrays is array (Index range <>) of Element;
        with function "<" (Left, Right : Element)
                           return        Boolean;
    procedure Sort (Arr : in out Arrays);

I consider this the usual data structure oriented approach.  Which is
a conventient form, but should be built on top of a more general
sorting algorithm:

    generic
        type Element is limited private;
        type Index is (<>);
        type Arrays is array (Index range <>) of Element;
        with function "<" (Left, Right : Element)
                           return        Boolean;
        with procedure Swap (Left, Right : in out Element);
    procedure Sort (Arr : in out Arrays);

Which could be built on another, even more general sorting algorithm:

    generic
        type Index   is (<>);
        with function Element_Is_Less_Than
                          (Left, Right : Index)
                           return        Boolean;
        with procedure Swap (Left, Right : in     Index);
    procedure Sort (From, To : in     Index);

And then I would even try to make Index limited private, but that
gets messy, and you get the idea.  When you get down to the actual
algorithm, you will have declared the assumptions that the algorithm
makes as part of the declaration.

So if you can describe the Quick_Sort algorithm using only limited
private types, and for a binary tree you have a way of partitioning
the tree, moving elements, comparing elements, etc.--then you have
an efficient sort that works both on arrays and binary trees.

             reply	other threads:[~1991-08-16 17:56 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-08-16 17:56 Doug Smith [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-08-30  7:24 c++ vs ada results Ma ts Henricson
1991-08-29 16:54 David Emery
1991-08-15 15:40 Andy Davidson
1991-08-15 13:30 Paul Baker - CTA
1991-08-14 20:15 Jim Showalter
1991-08-14 19:15 Doug Smith
1991-08-14 18:40 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!utgpu!
1991-08-14 18:25 Doug Smith
1991-08-14 14:41 Fred Stluka
1991-08-14  5:03 Mike Feldman
1991-08-13 22:08 David Emery
1991-08-13 14:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!qt.cs.utexas.edu!cs.utexas.e
1991-07-01  5:15 Andrew Dunstan
1991-06-27 18:24 Ray Diederich, 301-294-8400
1991-06-27 12:34 Chuck Shotton
     [not found] <164741@<1991Jun12>
1991-06-20 17:58 ` ryer
1991-06-24 14:44 ` ryer
1991-06-20 16:24 Chuck Shotton
1991-06-22  3:24 ` Thomas M. Breuel
1991-06-12 16:47 alan dare
1991-06-12 19:15 ` Paul Martz
1991-06-12 20:17 ` Jim Showalter
1991-06-13 20:49   ` Paul Kohlmiller
1991-06-13 23:12     ` Bruce Jones
1991-06-16  2:48   ` Russ Nelson
1991-06-16  4:10   ` Sean Eric Fagan
1991-06-18  4:17     ` Jim Showalter
1991-06-18  8:33       ` Sean Eric Fagan
1991-06-18 21:53         ` Jim Showalter
1991-06-18 12:28       ` Mats Henricson
1991-06-18 22:06         ` Jim Showalter
1991-06-19 15:07           ` Dan Weinreb
1991-06-19 17:00           ` Doug Smith
1991-06-20 14:08             ` Steve Juneau
1991-06-20 19:56               ` Robert I. Eachus
1991-06-21 17:27                 ` David M Geary
1991-06-20 22:09               ` Paul Stachour
1991-06-21 17:03                 ` David M Geary
1991-06-23  3:14                   ` Jim Showalter
1991-06-26 22:13                 ` Dan Weinreb
1991-06-21 22:01               ` Jim Showalter
1991-06-19 18:36           ` Jim Showalter
1991-06-19 15:01         ` Dan Weinreb
1991-06-24  2:29         ` Andrew Dunstan
1991-06-24 10:06           ` David Emery
1991-06-24 13:16           ` Mats Henricson
1991-06-25  4:29           ` Tom McClory
1991-06-26  0:35             ` Jim Showalter
1991-06-26  1:26             ` Andrew Dunstan
1991-06-26 22:47               ` Jim Showalter
1991-06-27 15:47                 ` Alex Blakemore
1991-06-27 23:58                   ` Jim Showalter
1991-06-25 19:27           ` Jim Showalter
1991-06-23 23:59       ` CBW Consulting
1991-06-24 20:11         ` Jim Showalter
1991-06-12 21:27 ` Dan L. Pierson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox