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,20b3b2fc48674108 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-03 10:54:12 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Preferred method for bringing in operators Date: 03 Jul 2001 13:49:45 -0400 Organization: NASA Goddard Space Flight Center Message-ID: References: <9hsnkr$90q$1@nh.pace.co.uk> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 994183590 26447 128.183.220.71 (3 Jul 2001 18:06:30 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 3 Jul 2001 18:06:30 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 Xref: archiver1.google.com comp.lang.ada:9387 Date: 2001-07-03T18:06:30+00:00 List-Id: "Marin David Condic" writes: > This is a question about style and preferences, rather than something purely > technical. I just want to know what people prefer and if there are any > reasons to consider one style superior to another... > > Suppose you build a class to represent a container of some objects. The > objects are just stored and retrieved from the container in no particular > order. Now you want to derive a child class from the container only in this > case you want to store and retrieve the objects in sorted order. That means > you have to somehow extend the class to bring in one or more comparison > operations for the object being stored. A variety of solutions exist: > You first need to decide if you are using a tagged type approach, or a generic approach. Since you said "class", I guess you are leaning towards tagged types, but then you talk about generics, so I'm not clear. For my answer to both approaches, see http://users.erols.com/leakstan/Stephe/Ada/sal.html Specifically, for the generic approach, sal-gen-alg.ads defines the notion of an algoirthm on a container, sal-gen-alg-find_linear.ads extends that to a 'find' alorgithm. Then sal-gen-alg-find_linear-sorted.ads extends that to a linear sorted list, and sal-gen-alg-find_binary.ads extends it to binary searching on a sorted container. For the tagged type approach, see sal-poly-alg.ads, sal-poly-alg-find_linear.ads. These are also generics, but the basic container is a tagged type. Hope this helps :). -- -- Stephe