Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/hash.sim
There is 1 other file named hash.sim in the archive. Click here to see a list.
OPTIONS(/E/C/-Q/-A/-I/-D);
COMMENT Procedure HASH returns a calculated hash value from a given
text T. The result is taken modulo N before return.
;
EXTERNAL TEXT PROCEDURE frontstrip;
INTEGER PROCEDURE hash(t,n);   TEXT t;  INTEGER n;
BEGIN   TEXT tstrip;  INTEGER a;

    tstrip:- frontstrip(t.Strip);
    IF tstrip == NOTEXT THEN hash:= Mod(t.Length,n) ELSE
    BEGIN
	a:= Rank(tstrip.Getchar);
	IF tstrip.Length > 3 THEN
	BEGIN
	    a:= a +   8*Rank(tstrip.Getchar);
	    a:= a +  64*Rank(tstrip.Getchar)
	END;
	tstrip.Setpos(tstrip.Length);
	a:= a + 512*Rank(tstrip.Getchar) + t.Length;
	hash:= Mod(a,n);
    END
END of hash;