(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10) (FILECREATED "10-Feb-2022 21:52:22" {DSK}larry>medley>lispusers>HASHBUFFER.;2 6788 :PREVIOUS-DATE "15-Sep-87 11:26:06" {DSK}larry>medley>lispusers>HASHBUFFER.;1) (* ; " Copyright (c) 1985-1987, 2022 by Stanford University. ") (PRETTYCOMPRINT HASHBUFFERCOMS) (RPAQQ HASHBUFFERCOMS ((FNS CREATEHASHBUFFER OPENHASHBUFFER CLOSEHASHBUFFER GETHASHBUFFER PUTHASHBUFFER) (INITVARS (EMPTYHASHENTRYMARKER '**EMPTYHASHENTRY**)) (GLOBALVARS EMPTYHASHENTRYMARKER) (FNS HASHARRAY.TO.HASHFILE HASHFILE.TO.HASHARRAY) (DECLARE%: DONTCOPY (RECORDS HASHBUFFER)) (FILES HASH))) (DEFINEQ (CREATEHASHBUFFER [LAMBDA (FILE VALUETYPE ITEMLENGTH %#ENTRIES OVERFLOW HASHBITSFN EQUIVFN) (* cdl " 1-May-87 16:08") (DECLARE (GLOBALVARS HASHFILEDEFAULTSIZE)) (PROG [(HASHBUFFER (create HASHBUFFER HASHFILE _ (CREATEHASHFILE FILE VALUETYPE ITEMLENGTH %#ENTRIES) HASHARRAY _ (HASHARRAY (OR %#ENTRIES HASHFILEDEFAULTSIZE) OVERFLOW HASHBITSFN EQUIVFN] (replace (HASHBUFFER ACCESS) of HASHBUFFER with (GETFILEINFO (with HashFile (with HASHBUFFER HASHBUFFER HASHFILE) Stream) 'ACCESS)) (RETURN HASHBUFFER]) (OPENHASHBUFFER [LAMBDA (FILE ACCESS MINKEYS OVERFLOW HASHBITSFN EQUIVFN) (* cdl " 1-May-87 16:10") (PROG [(HASHBUFFER (create HASHBUFFER HASHFILE _ (OPENHASHFILE FILE ACCESS] (replace (HASHBUFFER HASHARRAY) of HASHBUFFER with (HASHARRAY (OR MINKEYS (with HashFile (with HASHBUFFER HASHBUFFER HASHFILE) %#Entries)) OVERFLOW HASHBITSFN EQUIVFN)) (replace (HASHBUFFER ACCESS) of HASHBUFFER with (GETFILEINFO (with HashFile (with HASHBUFFER HASHBUFFER HASHFILE) Stream) 'ACCESS)) (RETURN HASHBUFFER]) (CLOSEHASHBUFFER [LAMBDA (HASHBUFFER FILEONLY?) (* cdl " 1-May-87 16:21") (with HASHBUFFER HASHBUFFER (PROG1 (HASHFILEPROP HASHFILE 'NAME) (CLOSEHASHFILE HASHFILE) (if (NOT FILEONLY?) then (SETQ HASHARRAY NIL]) (GETHASHBUFFER [LAMBDA (KEY HASHBUFFER) (* cdl "24-Oct-85 08:37") (PROG (VALUE) (with HASHBUFFER HASHBUFFER (if (EQ EMPTYHASHENTRYMARKER (SETQ VALUE (GETHASH KEY HASHARRAY ))) then (RETURN) elseif VALUE then (RETURN VALUE) elseif (SETQ VALUE (GETHASHFILE KEY HASHFILE)) then (PUTHASH KEY VALUE HASHARRAY) (RETURN VALUE) else (PUTHASH KEY EMPTYHASHENTRYMARKER HASHARRAY]) (PUTHASHBUFFER [LAMBDA (KEY VALUE HASHBUFFER) (* cdl "24-Oct-85 08:26") (with HASHBUFFER HASHBUFFER (if (NEQ ACCESS 'INPUT) then (PUTHASHFILE KEY VALUE HASHFILE)) (PUTHASH KEY VALUE HASHARRAY]) ) (RPAQ? EMPTYHASHENTRYMARKER '**EMPTYHASHENTRY**) (DECLARE%: DOEVAL@COMPILE DONTCOPY (GLOBALVARS EMPTYHASHENTRYMARKER) ) (DEFINEQ (HASHARRAY.TO.HASHFILE [LAMBDA (HASHARRAY HASHFILE TESTFN) (* ; "Edited 3-Sep-87 17:05 by cdl") (DECLARE (SPECVARS HASHARRAY HASHFILE TESTFN)) (LET (REOPEN) (DECLARE (SPECVARS REOPEN)) [if (HASHFILEP HASHFILE) then (SETQ REOPEN T) else (SETQ HASHFILE (CREATEHASHFILE HASHFILE NIL NIL (HARRAYPROP HASHARRAY 'NUMKEYS] [RESETLST [RESETSAVE NIL `(CLOSEHASHFILE ,HASHFILE ,REOPEN] (MAPHASH HASHARRAY (FUNCTION (LAMBDA (VALUE KEY) (if (OR (NULL TESTFN) (APPLY* TESTFN KEY VALUE HASHARRAY HASHFILE)) then (PUTHASHFILE KEY VALUE HASHFILE] (if REOPEN then HASHFILE else (with HashFile HASHFILE File]) (HASHFILE.TO.HASHARRAY [LAMBDA (HASHFILE HASHARRAY TESTFN) (* ; "Edited 3-Sep-87 17:05 by cdl") (DECLARE (SPECVARS HASHFILE HASHARRAY TESTFN)) (LET (REOPEN) (DECLARE (SPECVARS REOPEN)) [if (HASHFILEP HASHFILE) then (SETQ REOPEN T) else (SETQ HASHFILE (OPENHASHFILE HASHFILE 'INPUT] [if (NULL HASHARRAY) then (SETQ HASHARRAY (with HashFile HASHFILE (HASHARRAY %#Entries] [RESETLST [RESETSAVE NIL `(CLOSEHASHFILE ,HASHFILE ,REOPEN] (MAPHASHFILE HASHFILE (FUNCTION (LAMBDA (KEY VALUE) (if (OR (NULL TESTFN) (APPLY* TESTFN KEY VALUE HASHFILE HASHARRAY )) then (PUTHASH KEY VALUE HASHARRAY] HASHARRAY]) ) (DECLARE%: DONTCOPY (DECLARE%: EVAL@COMPILE (RECORD HASHBUFFER (HASHARRAY HASHFILE ACCESS)) ) ) (FILESLOAD HASH) (PUTPROPS HASHBUFFER COPYRIGHT ("Stanford University" 1985 1986 1987 2022)) (DECLARE%: DONTCOPY (FILEMAP (NIL (714 4484 (CREATEHASHBUFFER 724 . 1853) (OPENHASHBUFFER 1855 . 2947) (CLOSEHASHBUFFER 2949 . 3338) (GETHASHBUFFER 3340 . 4183) (PUTHASHBUFFER 4185 . 4482)) (4611 6569 ( HASHARRAY.TO.HASHFILE 4621 . 5556) (HASHFILE.TO.HASHARRAY 5558 . 6567))))) STOP