comp.lang.ada
 help / color / mirror / Atom feed
From: "NYGREN JONAS" <jonas.nygren@telia.com>
Subject: STL in Ada
Date: 1999/02/08
Date: 1999-02-08T00:00:00+00:00	[thread overview]
Message-ID: <36be1ed2.0@d2o41.telia.com> (raw)

I have started to read c.l.a after being away a long time. Found it
interesting
that the question of a 'standard' Ada library (for containers and
algorithms) still
is on the chart.

So I started to think of how one would implement a set of algorithms that
work
over a set of iterators with different capabilities, like in STL. I am
curious if anybody
have come up with any ideas of how this should be done?

I arrived at an outline for a solution given below - is this the best way to
go?

/jonas

-- the iterators:

generic
   type Item_Type is private;
package Iterator is

   -- To Do: Add abstract methods for each Iterator type

   -- A container would derive from the appropriate iterator type
   -- and implement the abstract methods (TBD)

   -- Possible Problem: Output_Iterator. As I understand it
   --                   Forward_Iterator inherits capabilities
   --                   from both Input as well as Output_Iterator
   --                   but there is no (?) way to describe this

   type Root is tagged null record;
   type Input is new Root with null record;
   type Output is new Root with null record;
   type Forward is new Input with null record;
   type Bidirectional is new Forward with null record;
   type Random is new Bidirectional with null record;
end Iterator;

-- the Algos

with Iterator;
generic
   with package An_Iterator is new Iterator (<>);
package Algo is
   generic
      function Less (A, B : An_Iterator.Item_Type) return Boolean;
   function Min (First, Tail : An_Iterator.Forward'Class) return Boolean;
end Algo;







             reply	other threads:[~1999-02-08  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-08  0:00 NYGREN JONAS [this message]
1999-02-12  0:00 ` STL in Ada Nick Roberts
replies disabled

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