Horrible-Hash

Hash as an erlang process


Project maintained by eiri Hosted on GitHub Pages — Theme by mattgraham

Module horrible_hash

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

Function Index

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.

Function Details

delete/1


delete(Name::atom()) -> boolean()


Delete existing hash.

delete/2


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/1


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/2


exists(Name::atom(), Key::any()) -> boolean()


Retrns true is a given key associated with a value in a hash. Otherwise returns false.

get/2


get(Name::atom(), Key::any()) -> Value::any() | undefined


Gets a value for a given key. If no value exists returns atom undefined.

keys/1


keys(Name::atom()) -> [Key::any()]


Returns a list of all the keys allocated in a hash. Order not guaranteed.

new/1


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/3


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/1


values(Name::atom()) -> [Value::any()]


Returns a list of all the values stored in a hash. Order not guaranteed.