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


2.29.4.4 Dealing with single elements

Function: hash-table-ref hash-table key
Function: hash-table-ref hash-table key thunk

This procedure returns the value associated to key in hash-table. If no value is associated to key and thunk is given, it is called with no arguments and its value is returned; if thunk is not given, an error is signalled.

Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table.

NOTE This rules out implementation by association lists or fixed–length hash tables.

Function: hash-table-ref/default hash-table key default

Evaluate to the same value as:

(hash-table-ref hash-table key (lambda () default))

Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table.

NOTE This rules out implementation by association lists or fixed–length hash tables.

Function: hash-table-set! hash-table key value

Set the value associated to key in hash-table. The previous association (if any) is removed.

Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table.

NOTE This rules out implementation by association lists or fixed–length hash tables.

Function: hash-table-delete! hash-table key

Remove any association to key in hash-table. It is not an error if no association for that key exists; in this case, nothing is done.

Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table.

NOTE This rules out implementation by association lists or fixed–length hash tables.

Function: hash-table-exists? hash-table key

Tell whether there is any association to key in hash-table; return a boolean.

Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table.

NOTE This rules out implementation by association lists or fixed–length hash tables.

Function: hash-table-update! hash-table key function
Function: hash-table-update! hash-table key function thunk

Semantically equivalent to, but may be implemented more efficiently than, the following code:

(hash-table-set! hash-table key
  (function (hash-table-ref hash-table key thunk)))
Function: hash-table-update!/default hash-table key function default

Behave as if it evaluates to:

(hash-table-update! hash-table key function
  (lambda () default))

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