From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Preferred method for bringing in operators
Date: 03 Jul 2001 13:49:45 -0400
Date: 2001-07-03T18:06:30+00:00 [thread overview]
Message-ID: <uith9nbra.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 9hsnkr$90q$1@nh.pace.co.uk
"Marin David Condic" <marin.condic.auntie.spam@pacemicro.com> 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:
> <snip>
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
next prev parent reply other threads:[~2001-07-03 17:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-03 15:16 Preferred method for bringing in operators Marin David Condic
2001-07-03 17:49 ` Stephen Leake [this message]
2001-07-03 19:04 ` Marin David Condic
2001-07-03 20:21 ` Stephen Leake
2001-07-03 23:04 ` tmoran
2001-07-05 14:04 ` Marin David Condic
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox