Next: , Previous: , Up: srfi hash-tables spec   [Index]


2.29.4.5 Dealing with the whole contents

Function: hash-table-size hash-table

Return an exact integer representing the number of associations in hash-table. This operation must have a complexity of O(1) with respect to the number of associations in hash-table.

Function: hash-table-keys hash-table

Return a list of keys in hash-table. The order of the keys is unspecified.

Function: hash-table-values hash-table

Return a list of values in hash-table. The order of the values is unspecified, and is not guaranteed to match the order of keys in the result of hash-table-keys.

Function: hash-table-walk hash-table proc

proc should be a function taking two arguments, a key and a value. This procedure calls proc for each association in hash-table, giving the key of the association as key and the value of the association as value. The results of proc are discarded. The order in which proc is called for the different associations is unspecified.

NOTE In some implementations, there is a procedure called hash-table-map which does the same as this procedure. However, in other implementations, hash-table-map does something else. In no implementation that I know of, hash-table-map does a real functorial map that lifts an ordinary function to the domain of hash tables. Because of these reasons, hash-table-map is left outside this SRFI.

Function: hash-table-fold hash-table f init-value

Call f for every association in hash-table with three arguments:

  1. The key of the association key.
  2. The value of the association value.
  3. An “accumulated value”, val.

val is init-value for the first invocation of f, and, for subsequent invocations of f, the return value of the previous invocation of f. The value final-value returned by hash-table-fold is the return value of the last invocation of f. The order in which f is called for different associations is unspecified.

Function: hash-table->alist hash-table

Return an association list such that the car of each element in alist is a key in hash-table and the corresponding cdr of each element in alist is the value associated to the key in hash-table. The order of the elements is unspecified.

The following should always produce a hash table with the same mappings as a hash table H:

(alist->hash-table (hash-table->alist h)
                   (hash-table-equivalence-function h)
                   (hash-table-hash-function h))
Function: hash-table-copy hash-table

Return a new hash table with the same equivalence predicate, hash function and mappings as in hash-table.

Function: hash-table-merge! hash-table1 hash-table2

Add all mappings in hash-table2 into hash-table1 and return the resulting hash table. This function may modify hash-table1 destructively.


Next: , Previous: , Up: srfi hash-tables spec   [Index]