Next: rnrs enums, Previous: rnrs syntax-case, Up: R6RS Standard Libraries [Contents][Index]
The (rnrs hashtables (6))
library provides structures and
procedures for creating and accessing hash tables. The hash tables API
defined by R6RS is substantially similar to both Guile’s native hash
tables implementation as well as the one provided by SRFI-69;
See Hash Tables, and SRFI-69, respectively. Note that you can
write portable R6RS library code that manipulates SRFI-69 hash tables
(by importing the (srfi :69)
library); however, hash tables
created by one API cannot be used by another.
Like SRFI-69 hash tables—and unlike Guile’s native ones—R6RS hash
tables associate hash and equality functions with a hash table at the
time of its creation. Additionally, R6RS allows for the creation
(via hashtable-copy
; see below) of immutable hash tables.
Returns a new hash table that uses eq?
to compare keys and
Guile’s hashq
procedure as a hash function. If k is given,
it specifies the initial capacity of the hash table.
Returns a new hash table that uses eqv?
to compare keys and
Guile’s hashv
procedure as a hash function. If k is given,
it specifies the initial capacity of the hash table.
Returns a new hash table that uses equiv to compare keys and
hash-function as a hash function. equiv must be a procedure
that accepts two arguments and returns a true value if they are
equivalent, #f
otherwise; hash-function must be a procedure
that accepts one argument and returns a non-negative integer.
If k is given, it specifies the initial capacity of the hash table.
Returns #t
if obj is an R6RS hash table, #f
otherwise.
Returns the number of keys currently in the hash table hashtable.
Returns the value associated with key in the hash table hashtable, or default if none is found.
Associates the key key with the value obj in the hash table
hashtable, and returns an unspecified value. An &assertion
condition is raised if hashtable is immutable.
Removes any association found for the key key in the hash table
hashtable, and returns an unspecified value. An &assertion
condition is raised if hashtable is immutable.
Returns #t
if the hash table hashtable contains an
association for the key key, #f
otherwise.
Associates with key in the hash table hashtable the result
of calling proc, which must be a procedure that takes one
argument, on the value currently associated key in
hashtable—or on default if no such association exists.
An &assertion
condition is raised if hashtable is
immutable.
Returns a copy of the hash table hashtable. If the optional argument mutable is provided and is a true value, the new hash table will be mutable.
Removes all of the associations from the hash table hashtable.
The optional argument k, which specifies a new capacity for the
hash table, is accepted by Guile’s (rnrs hashtables)
implementation, but is ignored.
Returns a vector of the keys with associations in the hash table hashtable, in an unspecified order.
Return two values—a vector of the keys with associations in the hash table hashtable, and a vector of the values to which these keys are mapped, in corresponding but unspecified order.
Returns the equivalence predicated use by hashtable. This
procedure returns eq?
and eqv?
, respectively, for hash
tables created by make-eq-hashtable
and
make-eqv-hashtable
.
Returns the hash function used by hashtable. For hash tables
created by make-eq-hashtable
or make-eqv-hashtable
,
#f
is returned.
Returns #t
if hashtable is mutable, #f
otherwise.
A number of hash functions are provided for convenience:
Returns an integer hash value for obj, based on its structure and
current contents. This hash function is suitable for use with
equal?
as an equivalence function.
These procedures are identical to the ones provided by Guile’s core library. See Hash Table Reference, for documentation.
Returns an integer hash value for string based on its contents,
ignoring case. This hash function is suitable for use with
string-ci=?
as an equivalence function.
Next: rnrs enums, Previous: rnrs syntax-case, Up: R6RS Standard Libraries [Contents][Index]