comp.lang.ada
 help / color / mirror / Atom feed
* STL in Ada
@ 1999-02-08  0:00 NYGREN JONAS
  1999-02-12  0:00 ` Nick Roberts
  0 siblings, 1 reply; 2+ messages in thread
From: NYGREN JONAS @ 1999-02-08  0:00 UTC (permalink / 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;







^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-02-12  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-08  0:00 STL in Ada NYGREN JONAS
1999-02-12  0:00 ` Nick Roberts

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