PROCEDURE IterateHash(hash: Hash);
(* start iteration of hash *)
BEGIN
hash.nextval := 0; hash.nextentry := hash.bucket[0];
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;
|