1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2% 3% File: PK:HASH-DECLS.SL 4% Description: Declarations for access to the hash table. 5% Author: Brian Beach, Hewlett-Packard CRC 6% Created: 22-Feb-84 7% Modified: 04-Jun-84 09:13:06 (Brian Beach) 8% Mode: Lisp 9% Package: 10% Status: Experimental (Do Not Distribute) 11% Compile to: PL:HASH-DECLS.B 12% 13% (c) Copyright 1983, Hewlett-Packard Company, see the file 14% HP_disclaimer at the root of the PSL file tree 15% 16%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 18% 19% Special values for labelling unoccupied slots: 20% 21 22(define-constant deleted-slot-value 16#ffff) 23(define-constant empty-slot-value 0) 24 25% 26% Predicates for unoccupied slots: 27% 28 29(ds deleted-slot? (u) 30 (weq (hash-table-entry u) deleted-slot-value)) 31 32(ds empty-slot? (u) 33 (weq (hash-table-entry u) empty-slot-value)) 34 35(ds occupied-slot? (u) 36 (let ((hte (hash-table-entry u))) 37 (and (< hte 16#ffff) (> hte 0))) 38 ) 39 40% 41% Assorted macros: 42% 43 44(ds next-slot (h) 45 % Increment to the next slot in the hash table, wrapping around at the end. 46 (if (eq h hash-table-size) 47 0 48 (wplus2 h 1))) 49 50(ds equal-hash-entry (hash-index s) 51 % Compare the name of the ID at HASH-INDEX with S. 52 (unchecked-string-equal (symnam (hash-table-entry hash-index)) s)) 53 54(ds hash-table-entry (i) 55 % Access to an element of the hash table. 56 (field (halfword hashtable i) 57 bitsperword2 58 bitsperword2)) 59 60(ds set-hash-table-entry (i x) 61 (setf (halfword hashtable i) x)) 62 63(put 'hash-table-entry 'assign-op 'set-hash-table-entry) 64