DEFINITION MODULE Lists;

(* 
   A Demo of lists object
   Copyright (C) 1996 by Marcel Timmermans
*)

FROM Objects IMPORT TObject;
FROM SYSTEM IMPORT ADDRESS;

TYPE
 NodePtr = POINTER TO Node;
 Node    =  RECORD
             next:NodePtr;
             prev:NodePtr;
             data:ADDRESS;
            END;


 (* Convention is to start a Object with 'T' *)

 TList  = CLASS(TObject)         (* Convention is to inheritage from TObject *)
            head,tail:NodePtr;
            elements:LONGINT;
            CONSTRUCTOR Init;    (* Will always be called with NEW(xx)  *)
            PROCEDURE Add(d:ADDRESS);
            PROCEDURE DoProc(d:ADDRESS);
            PROCEDURE DoForward;
            PROCEDURE DoBackward;
            PROCEDURE CountElements():LONGINT;
            PROCEDURE Prev(n:NodePtr):NodePtr;
            PROCEDURE Next(n:NodePtr):NodePtr;
            PROCEDURE FreeData(d:ADDRESS);
            PROCEDURE Destroy;
          END;

END Lists.
