(FILECREATED " 5-Aug-84 15:09:27" {PHYLUM}<HUTTENLOCHER>LISP>STRHASH.;9 4833   

      changes to:  (FNS GETSTRHASH MODSTRHASH PUTSTRHASH MAPSTRHASH)
		   (VARS STRHASHCOMS)
		   (RECORDS STRHASHENTRY)

      previous date: " 5-Aug-84 14:11:32" {PHYLUM}<HUTTENLOCHER>LISP>STRHASH.;5)


(PRETTYCOMPRINT STRHASHCOMS)

(RPAQQ STRHASHCOMS ((FNS CLRSTRHASH GETSTRHASH MAPSTRHASH MODSTRHASH PUTSTRHASH STRINGHASH)
		    (RECORDS STRHASHENTRY)))
(DEFINEQ

(CLRSTRHASH
  [LAMBDA (ARRAY)                                            (* edited: " 5-Aug-84 12:43")
    (FOR INDEX FROM 1 TO (ARRAYSIZE ARRAY) DO (SETA ARRAY INDEX NIL])

(GETSTRHASH
  [LAMBDA (KEY ARRAY)                                        (* edited: " 5-Aug-84 14:51")
    (PROG ((SIZE (ARRAYSIZE ARRAY))
	   STARTINDEX THISKEY)
          (RETURN (OR [for INDEX from (SETQ STARTINDEX (IREMAINDER (STRINGHASH KEY)
								   SIZE))
			 to SIZE
			 do (SETQ THISKEY (fetch (STRHASHENTRY KEY) of (ELT ARRAY INDEX)))
			    (COND
			      [(STREQUAL THISKEY KEY)
				(RETURN (fetch (STRHASHENTRY VAL) of (ELT ARRAY INDEX]
			      ((NULL THISKEY)
				(RETURN NIL]
		      (for INDEX from 1 to STARTINDEX
			 do (SETQ THISKEY (fetch (STRHASHENTRY KEY) of (ELT ARRAY INDEX)))
			    (COND
			      [(STREQUAL THISKEY KEY)
				(RETURN (fetch (STRHASHENTRY VAL) of (ELT ARRAY INDEX]
			      ((NULL THISKEY)
				(RETURN NIL])

(MAPSTRHASH
  [LAMBDA (ARRAY MAPFN)                                      (* edited: " 5-Aug-84 14:24")
                                                             (* this function assume STRHASHENTRY is a list of 
							     (VAL KEY))
    (for INDEX from 1 to (ARRAYSIZE ARRAY) do (PROG ((ENTRY (ELT ARRAY INDEX)))
						    (COND
						      ((fetch (STRHASHENTRY KEY) of ENTRY)
							(APPLY MAPFN ENTRY])

(MODSTRHASH
  [LAMBDA (KEY MODFN ARRAY OTHERARGS)                        (* edited: " 5-Aug-84 15:02")
    (PROG ((SIZE (ARRAYSIZE ARRAY))
	   INITIALINDEX THISKEY)
          (RETURN (OR [for INDEX from (SETQ INITIALINDEX (IREMAINDER (STRINGHASH KEY)
								     SIZE))
			 to SIZE
			 do (SETQ THISKEY (fetch (STRHASHENTRY KEY) of (ELT ARRAY INDEX)))
			    (COND
			      [(STREQUAL THISKEY KEY)
				(RETURN (replace (STRHASHENTRY VAL) of (ELT ARRAY INDEX)
					   with (APPLY MODFN (CONS (fetch (STRHASHENTRY VAL)
								      of (ELT ARRAY INDEX))
								   OTHERARGS]
			      ((NULL THISKEY)
				(RETURN (SETA ARRAY INDEX (create STRHASHENTRY
								  KEY ← KEY
								  VAL ← (APPLY MODFN
									       (CONS NIL OTHERARGS]
		      (for INDEX from 1 to INITIALINDEX
			 do (SETQ THISKEY (fetch (STRHASHENTRY KEY) of (ELT ARRAY INDEX)))
			    (COND
			      [(STREQUAL THISKEY KEY)
				(RETURN (replace (STRHASHENTRY VAL) of (ELT ARRAY INDEX)
					   with (APPLY MODFN (CONS (fetch (STRHASHENTRY VAL)
								      of (ELT ARRAY INDEX))
								   OTHERARGS]
			      ((NULL THISKEY)
				(RETURN (SETA ARRAY INDEX (create STRHASHENTRY
								  KEY ← KEY
								  VAL ← (APPLY MODFN
									       (CONS NIL OTHERARGS])

(PUTSTRHASH
  [LAMBDA (KEY VAL ARRAY)                                    (* edited: " 5-Aug-84 14:53")
    (PROG ((SIZE (ARRAYSIZE ARRAY))
	   STARTINDEX THISKEY)
          (COND
	    ([NOT (OR [for INDEX from (SETQ STARTINDEX (IREMAINDER (STRINGHASH KEY)
								   SIZE))
			 to SIZE
			 do (SETQ THISKEY (fetch (STRHASHENTRY KEY) of (ELT ARRAY INDEX)))
			    (COND
			      ((STREQUAL THISKEY KEY)
				(RETURN (replace (STRHASHENTRY VAL) of (ELT ARRAY INDEX)
					   with VAL)))
			      ((NULL THISKEY)
				(RETURN (SETA ARRAY INDEX (create STRHASHENTRY
								  VAL ← VAL
								  KEY ← KEY]
		      (for INDEX from 1 to STARTINDEX
			 do (SETQ THISKEY (fetch (STRHASHENTRY KEY) of (ELT ARRAY INDEX)))
			    (COND
			      ((STREQUAL THISKEY KEY)
				(RETURN (replace (STRHASHENTRY VAL) of (ELT ARRAY INDEX)
					   with VAL)))
			      ((NULL THISKEY)
				(RETURN (SETA ARRAY INDEX (create STRHASHENTRY
								  VAL ← VAL
								  KEY ← KEY]
	      (ERROR "String Hash Table Overflow in PUTSTRHASH"])

(STRINGHASH
  [LAMBDA (STRING)                                           (* edited: " 5-Aug-84 12:17")
    (PROG ((NUM 0))
          [for I from 1 to (SUB1 (STRPOS STRING STRING NIL NIL NIL T))
	     do (SETQ NUM (LOGAND 32767 (IPLUS NUM (LSH (NTHCHARCODE STRING I)
							I]
          (RETURN NUM])
)
[DECLARE: EVAL@COMPILE 

(RECORD STRHASHENTRY (VAL KEY))
]
(PUTPROPS STRHASH COPYRIGHT (NONE))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (447 4712 (CLRSTRHASH 457 . 653) (GETSTRHASH 655 . 1482) (MAPSTRHASH 1484 . 1934) (
MODSTRHASH 1936 . 3279) (PUTSTRHASH 3281 . 4385) (STRINGHASH 4387 . 4710)))))
STOP