hash
Class constructoris.hash
test if object is of class "hash"
as.list
as.list.hash
convert a hash object to
a list
KEYS must be a valid R name, must be a character
vector and must not be the empty string, ""
. When
supplied by the used methods will try to coerce the keys to
valid names using make.keys
VALUES are restricted to any valid R objects. HASH
VALUES can be any R value, vector or object.
code{hash} returns a hash object. Key-value pairs
may be specified via the ...
argument as explicity
arguments keys
and values
, as named key-value
pairs, as a named vector or as implicit key, value vectors.
See examples below for each type. See .set
for further details and how key-value vectors of unequal
length are interpretted.
ACCESSORS. Hashes may be accessed via the standard R
accessors [
, [[
and $
. See
Extract
for details.
PASS-BY REFERENCE. Environments and hashes are
special objects in R because only one copy exists globally.
When provided as an argument to a function, no local copy
is made. When passes to functions, those functions can
change the value of the hash. This is not typical of R.
PERFORMANCE. Hashes are based on R's native
environments and are designed to be exceedingly fast using
the environments internal hash table. For small data
structures, a list will out-perform a hash in nearly every
case. For larger data structure, i.e. > 500 key value pair
the performance of the hash becomes faster. Much beyond
that the performance of the hash far outperforms native
lists.
Return the number of items in the hash by calling
length
on the internal environment.