comp.lang.ada
 help / color / mirror / Atom feed
* Array Iterator
@ 1998-10-11  0:00 Gregory Mewborn
  1998-10-11  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 2+ messages in thread
From: Gregory Mewborn @ 1998-10-11  0:00 UTC (permalink / raw)


How do i create a set iterator for a set using a boolean array.


I begin with:

package integer_Set is
type Integer_Range is integer (1..100);
type set is limited private;
type set_Iteration is limited private;

procedure start_set_Iter (S: Set);
function more (S_Iter: Set_Iteration);
Procedure next_element (S_Iter: Set_Iteration);


private
type Set array (Integer_RANGE) of Boolean;

-- how do i write a Set_Iteration to use the the above functions and
procedures and to work with the Set array?




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

* Re: Array Iterator
  1998-10-11  0:00 Array Iterator Gregory Mewborn
@ 1998-10-11  0:00 ` Matthew Heaney
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Heaney @ 1998-10-11  0:00 UTC (permalink / raw)


Gregory Mewborn <mewborn@erols.com> writes:

You don't have to use an ADT.  You could just use an array:

   subtype Set_Element is Integer range 1 .. 100;

   type Set_Type is array (Set_Element) of Boolean;

Then "set iteration" is just iteration over the array:

   for Element in Set_Element loop
      if Set (Element) then
         <Element is in set, do something with it>
      end if;
   end loop;

Will that do?


> How do i create a set iterator for a set using a boolean array.
> 
> 
> I begin with:
> 
> package integer_Set is
> type Integer_Range is integer (1..100);
> type set is limited private;
> type set_Iteration is limited private;
> 
> procedure start_set_Iter (S: Set);
> function more (S_Iter: Set_Iteration);
> Procedure next_element (S_Iter: Set_Iteration);
> 
> 
> private
> type Set array (Integer_RANGE) of Boolean;
> 
> -- how do i write a Set_Iteration to use the the above functions and
> procedures and to work with the Set array?




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

end of thread, other threads:[~1998-10-11  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-11  0:00 Array Iterator Gregory Mewborn
1998-10-11  0:00 ` Matthew Heaney

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