| makeHashTable | Function |
| makeHashTable test | Function |
| makeHashTable test size | Function |
makeHashTable returns a new Lpp hash table object. If the
optional argument test is given it should be a predicate
function object of two arguments that returns nil unless the
two arguments representing hash table keys are considered equal by the
definition of the function. Or test may be one of the symbols:
eq, eql or equal which would correspond to the
function of that symbol name. If test is not given or
nil it is assumed to be the eql function.
The optional argument size if given should be an positive
integer argument specifying the size of the hash table. size
may be of type int or Lpp Integer. If size is not given
or nil then a default size of approximately 500 is used. The
user is encouraged here to either use the default size or study how to
compute the optimal size of hash tables (See Knuth "Art of Computer
Programming"). Although all sizes will work under Lpp some sizes
will result in better distributions.
| puthash key table value | Function |
puthash creates an entry for key with value value
in the hash table table. If the key entry already
exists in table then its value is replaced with value.
value is returned.
| gethash key table | Function |
| gethash key table default | Function |
gethash finds the entry for key in the hash table
table and returns the entry value. If not found it returns
nil. If the optional third argument default is
specified and the key is not found default is returned
instead of nil.
Here is an example:
let table = makeHashTable();
let max = L(100); let min = L(0);
puthash(S(red), table, list(max, min, min));
puthash(S(green), table, list(min, max, min));
gethash(S(blue), table) => nil
gethash(S(red), table) => (100 0 0)
| remhash key table | Function |
remhash removes the entry for key in hash table
table. This is also a predicate that returns t if there
was an entry and nil if not.
| clrhash table | Function |
clrhash removes all entry from the hash table table and
returns table.
| hashTableCount table | Function |
| hashTableCountL table | Function |
hashTableCount returns the number of entries in hash table
table as an int. hashTableCountL does the same
but returns an Lpp Integer. A hash table starts out with zero
entries.
| maphash function table | Function |
For each entry in hash table table maphash calls
function function on two arguments: the key of the entry and
the value of the entry. For example the following maphash
would display the key and value for all entries in hash table
ht
let printKeyValue(let key, let value) {
princ(" key = "); prin1(key);
princ(" value = "); prin1(value); terpri();
return Nil;}
maphash(L(printKeyValue), ht);