Listing Sequence Class Body
MC logo

Listing Sequence Class Body

Ada Code Examples

<<Listing Sequence Class Download Polymorphic Driver>>
with Gnat.Io; use Gnat.Io;

package body ListSeq is
   -- Set the sequence.
   procedure SetList(S: out ListSequence; A: SeqList) is
      S.List := new SeqList(A'Range);
      S.List.all := A;
      S.Which := S.List.all'First;
   end SetList;

   -- Standard procedures.

   -- Go to the next integer, wrap around.
   procedure Next(S: in out ListSequence) is
      S.Which := S.Which + 1;
      if S.Which > S.List.all'Last then
         S.Which := S.List.all'First;
      end if;
   end Next;

   -- Get the current item.
   function Value(S: ListSequence) return Integer is
      return S.List.all(S.Which);
   end Value;

end ListSeq;
<<Listing Sequence Class Polymorphic Driver>>