(*
    Title: 	Iterator things
    LastEdit:	"Fri Dec 18 17:11:04 1987"
    Author: 	Derek McAuley,Oms1,4663,329629
		Cambridge University Computer Laboratory
*)

DEFINITION MODULE Iterator;

EXPORT QUALIFIED
  Bit, Bits, Generation, State, EndedOrNot,
  
  Init, Starting, Broken, Finished, Exhausted, Break, Finish, Exhaust, Check;


TYPE
  Bit = (St, Br, Fin, Ex);
  Bits = SET OF Bit;
  Generation = INTEGER;
  State =
    RECORD
      pos: CARDINAL;
      gen: Generation;
      bits:Bits
    END;
  EndedOrNot = (Ended, NotEnded);


PROCEDURE Init(VAR s:State);

PROCEDURE Broken(VAR s:State):BOOLEAN;

PROCEDURE Finished(VAR s:State):BOOLEAN;

PROCEDURE Starting(VAR s:State):BOOLEAN;

PROCEDURE Exhausted(VAR s:State):BOOLEAN;

PROCEDURE Break(VAR s:State);

PROCEDURE Finish(VAR s:State);

PROCEDURE Exhaust(VAR s:State);

PROCEDURE Check(
  VAR state:     State;     (* InOut *)
      generation:Generation;
      startValue:CARDINAL
 ):CARDINAL;

END Iterator.
