comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Array Iterator
Date: 1998/10/11
Date: 1998-10-11T00:00:00+00:00	[thread overview]
Message-ID: <m3zpb31nci.fsf@mheaney.ni.net> (raw)
In-Reply-To: 3620C16B.3910@erols.com

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?




      reply	other threads:[~1998-10-11  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-11  0:00 Array Iterator Gregory Mewborn
1998-10-11  0:00 ` Matthew Heaney [this message]
replies disabled

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