Hash as an erlang process
Module horrible_hash
is an implementation of (perl) hash as an erlang process.
Copyright (c) 2016 Eric Avdey
Version: 0.1
Authors: Eric Avdey (eiri@eiri.ca
).
References* https://github.com/eiri/horrible-hash
delete/1 | Delete existing hash. |
delete/2 | Removes a given key from a hash. |
each/1 | Returns iterator for a hash. |
exists/2 | Retrns true is a given key associated with a value in a hash. |
get/2 | Gets a value for a given key. |
keys/1 | Returns a list of all the keys allocated in a hash. |
new/1 | Creates a new hash with a given name. |
set/3 | Sets a value for a given key. |
values/1 | Returns a list of all the values stored in a hash. |
delete(Name::atom()) -> boolean()
Delete existing hash.
delete(Name::atom(), Key::any()) -> boolean()
Removes a given key from a hash. Returns true even if the hash doesn't have the key.
each(Name::atom()) -> [{Key::any(), Value::any()}]
Returns iterator for a hash. On each call returns a tuple of {Key, Value} until end is reached. At which moment returns an empty list. Repeated call will initiate a new iterator.
exists(Name::atom(), Key::any()) -> boolean()
Retrns true is a given key associated with a value in a hash. Otherwise returns false.
get(Name::atom(), Key::any()) -> Value::any() | undefined
Gets a value for a given key. If no value exists returns atom undefined.
keys(Name::atom()) -> [Key::any()]
Returns a list of all the keys allocated in a hash. Order not guaranteed.
new(Name::atom()) -> true
Creates a new hash with a given name. Internally creates a registred process with hash name that uses process dictionary to hold provided values.
set(Name::atom(), Key::any(), Value::any()) -> boolean()
Sets a value for a given key. If the key already has a value, overrides it.
values(Name::atom()) -> [Value::any()]
Returns a list of all the values stored in a hash. Order not guaranteed.