ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

DEFINITION MODULE DblLnkLists;

  (*******************************************************************

    Module  DblLnkLists     (Version 1.0)

      Copyright (c) 1998-2006 by Andreas Fischlin and ETH Zurich.

    Purpose   Most basic routines for dynamic, doubly linked lists.

    Remarks   Does not install a terminate procedure.


    Programming

      o Design
        Andreas Fischlin          03/05/1998

      o Implementation
        Andreas Fischlin          03/05/1998


    ETH Zurich
    Systems Ecology
    CHN E 35.1
    Universitaetstrasse 16
    8092 Zurich
    SWITZERLAND

    URLs:
        <mailto:RAMSES@env.ethz.ch>
        <http://www.sysecol.ethz.ch>
        <http://www.sysecol.ethz.ch/SimSoftware/RAMSES>


    Last revision of definition:  03/05/1998  AF

  *******************************************************************)


  FROM SYSTEM IMPORT ADDRESS;

  TYPE
    EnclosingItemPtr  = ADDRESS;
    DMLevel           = CARDINAL;
    ListItemRec       = RECORD
                          lev: DMLevel;
                          prev,next: EnclosingItemPtr;
                        END;
    (*
       These module assumes you will define your enclosing data
       structure as this:

      EnclosingItemPtr = POINTER TO EnclosingItemRec;
      EnclosingItemRec = RECORD
                          li: ListItemRec; (* must be 1st field! *)
                          yourfields:  ...
                          ...
                         END;

      This means the doubly linking of the list items must be done
      by declaring as the first field in your data structure a
      field of type ListItemRec.
    *)


  VAR
    nilItemRec: ListItemRec; (* read only *)

  PROCEDURE AddToList(q: EnclosingItemPtr; VAR root,tail: EnclosingItemPtr);
  PROCEDURE RemoveFromList(q: EnclosingItemPtr; VAR root,tail: EnclosingItemPtr);

  PROCEDURE ListItemExists(q,root: EnclosingItemPtr): BOOLEAN;
  (* works simply if ListItemRec is first field in enclosing item's RECORD *)


END DblLnkLists.

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]