add(dic, key, value)
If key
not yet in dic
,
insert value
at key
, otherwise signal an error.
discard(dic, key)
If key
in dic
, remove it.
has(dic, key)
TRUE if key
in dic
else FALSE.
remove(dic, key)
If key
in dic
, remove it,
otherwise raise an error.
getval(dic)
If key
in dic
, return value, else
throw key-error.
keys(dic)
Return a character vector of all keys.
peek(dic, key, default=NULL)
Return the value for key
if
key
is in the dic
, else default
.
pop(dic, key)
If key
in dic
, return a copy of its
value and discard it afterwards.
popitem(dic)
Remove and return an arbitrary (key, value) pair
from the dictionary. popitem()
is useful to destructively iterate
over a dic
, as often used in set algorithms.
setval(dic, key, value, add=FALSE)
Like add
but overwrites
value if key
is already in the dic
. If key
not in
dic
, an error is thrown unless add
was set to
TRUE
.
sortkey(dic, decr=FALSE)
Sort values in dictionary according to keys.
update(dic, other=dict())
Adds element(s) of other to the
dictionary if the key(s) are not in the dictionary and updates all keys with
the new value(s) otherwise.