Implementierung assoziativer Arrays VIII

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

Hashes.om
PROCEDURE IterateHash(hash: Hash);
   (* start iteration of hash *)
BEGIN
   hash.nextval := 0; hash.nextentry := NIL;
END IterateHash;

PROCEDURE Next(hash: Hash;
               VAR object: Objects.Object) : BOOLEAN;
   (* store next object of iteration into object;
      note that the order of objects is undefined;
      returns FALSE on end of iteration
   *)
BEGIN
   IF hash.nextentry = NIL THEN
      WHILE (hash.nextval < tabsize) &
            (hash.bucket[hash.nextval] = NIL) DO
         INC(hash.nextval);
      END;
      IF hash.nextval >= tabsize THEN
         RETURN FALSE
      END;
      hash.nextentry := hash.bucket[hash.nextval];
      INC(hash.nextval);
   END;
   object := hash.nextentry.object;
   hash.nextentry := hash.nextentry.next;
   RETURN TRUE
END Next;

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1999, 2004, 2005 Andreas Borchert, in HTML konvertiert am 14.09.2005