From: Mats Weber <Mats.Weber@elca-matrix.ch>
Subject: Re: Q: Primitive operation of a type
Date: 1997/07/08
Date: 1997-07-08T00:00:00+00:00 [thread overview]
Message-ID: <33C24D61.86746FC7@elca-matrix.ch> (raw)
In-Reply-To: mheaney-ya023680000307972316390001@news.ni.net
Matthew Heaney wrote:
> package Sets_G is
>
> type Root_Set is abstract tagged private;
>
> type Root_Set_Iterator is abstract tagged private;
>
> function New_Iterator (Set : access Root_Set)
> return Root_Set_Iterator'Class;
>
> function Is_Done (Iterator : Root_Set_Iterator) return Boolean;
>
> procedure Advance (Iterator : in out Root_Set_Iterator);
>
> function Is_Equal (L : Root_Set'Class; R : Root_Set) return
> Boolean;
>
> procedure Copy (From : Root_Set'Class; To : in out Root_Set);
>
> ...
How about an iterator that is just a procedure ? That way, the iterator is
part of the primitive profile of the type and gets inherited (and I'll have to
convert all my Ada 83 iterator specifications based on generics :-().
Moreover, it's not always easy to implement an iterator that is a separate
type, e.g. if the structure is implemented as an AVL tree, you have to
remember the path from the root of the tree to the current node, which makes
your iterator less efficent.
generic
type element_type is private;
package sets is
type set is abstract tagged private;
type action_procedure is
access procedure (element : in element_type);
procedure enumerate (the_set : in set;
action : in action_procedure);
...
end sets;
next prev parent reply other threads:[~1997-07-08 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-25 0:00 Q: Primitive operation of a type Van Snyder
1997-07-01 0:00 ` Matthew Heaney
1997-07-02 0:00 ` Mats Weber
1997-07-03 0:00 ` Matthew Heaney
1997-07-08 0:00 ` Mats Weber [this message]
1997-07-14 0:00 ` Matthew Heaney
1997-07-02 0:00 ` Martin C. Carlisle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox