home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / GPMsym / cardsequences.def < prev    next >
Text File  |  1996-08-29  |  3KB  |  61 lines

  1. (****************************************************************)
  2. (*                                                              *)
  3. (*         Gardens Point Modula-2 Library Definition            *)
  4. (*                                                              *)
  5. (*                                                              *)
  6. (*     (c) Copyright 1996 Faculty of Information Technology     *)
  7. (*              Queensland University of Technology             *)
  8. (*                                                              *)
  9. (*     Permission is granted to use, copy and change this       *)
  10. (*     program as long as the copyright message is left intact  *)
  11. (*                                                              *)
  12. (****************************************************************)
  13.  
  14. (*******************************************************************)
  15. (******** support for cardinal sequences...no random access ********)
  16. (*******************************************************************)
  17.  
  18. (* !NONREC *) DEFINITION MODULE CardSequences; (* kjg nov '84 *)
  19.  
  20. TYPE ElemPtr;
  21. TYPE Sequence = RECORD
  22.                   first : ElemPtr; (* ptr to first element *)
  23.                   last  : ElemPtr  (* ptr to last element  *)
  24.                 END;
  25.  
  26. PROCEDURE InitSequence(VAR seq : Sequence);
  27.           (* sets all fields NIL *)
  28.  
  29. PROCEDURE LinkLeft (VAR seq : Sequence; Element : CARDINAL);
  30. PROCEDURE LinkRight(VAR seq : Sequence; Element : CARDINAL);
  31.  
  32. PROCEDURE InitCursor(seq : Sequence; VAR cursor : ElemPtr);
  33. (* postcondition: cursor is attached. GetNext will get first. *)
  34.  
  35. PROCEDURE GetFirst(       seq : Sequence;
  36.                    VAR cursor : ElemPtr;
  37.                    VAR result : CARDINAL );
  38. (* returns the first element. GetFirst on empty sequence rtns NIL *)
  39. (* postcondition: cursor is attached, next GetNext will fetch 2nd *)
  40.  
  41. PROCEDURE GetNext( VAR cursor : ElemPtr;
  42.                    VAR result : CARDINAL);
  43. (* precondition: cursor is already attached. Returns element and- *)
  44. (* "increments" cursor. Returns NIL if sequence is already ended. *)
  45.  
  46. PROCEDURE Ended(cursor : ElemPtr) : BOOLEAN;
  47. (* precondition: cursor is attached. Returns "cursor = NIL" *)
  48.  
  49. PROCEDURE NextIsLast(cursor : ElemPtr) : BOOLEAN;
  50. (* precondition: cursor is attached. Returns "cursor = seq.last" *)
  51.  
  52. PROCEDURE IsEmpty(seq : Sequence) : BOOLEAN;
  53. (* postcondition : returns "seq is the empty sequence" *)
  54.  
  55. PROCEDURE LengthOf(seq : Sequence) : CARDINAL;
  56.  
  57. PROCEDURE DisposeList(VAR seq : Sequence);
  58.       (* reinitializes the sequence header *)
  59.  
  60. END CardSequences.
  61.