RopeHash.mesa
Copyright Ó 1984, 1986, 1991 Xerox Corporation. All rights reserved.
Michael Plass, January 18, 1985 12:48:44 pm PST
Russ Atkinson (RRA) January 31, 1985 5:12:06 pm PST
Doug Wyatt, November 13, 1986 7:03:16 pm PST
Carl Hauser, January 17, 1988 2:06:37 pm PST
DIRECTORY
Rope USING [ROPE];
RopeHash: CEDAR DEFINITIONS
= BEGIN
ROPE: TYPE = Rope.ROPE;
PureText: TYPE = REF READONLY TEXT;
defaultSeed: CARDINAL = 31415;
FromRefText: PROC [text: PureText, seed: CARDINAL ¬ defaultSeed] RETURNS [hash: CARDINAL];
Computes a hash code given a REF TEXT object and an initial seed. Every character contributes to the hash. There is no case option (if one is needed, use FromRope).
FromRope: PROC [rope: Rope.ROPE, case: BOOL ¬ TRUE, start: INT ¬ 0, len: INT ¬ LAST[INT],
seed: CARDINAL ¬ defaultSeed] RETURNS [hash: CARDINAL];
Computes a hash code given a range of characters in a rope, a case indicator, and an initial seed. Every character contributes to the hash. If case, then case of characters matters, otherwise upper case and lower case characters hash to the same value (case = TRUE is faster). A BoundsFault is raised if start NOT IN [0..Rope.Length[rope]]. The hash returned will be the initialSeed if Length[rope] <= 0.
END.