NAME

Clownfish::Hash - Hashtable.

SYNOPSIS

my $hash = Clownfish::Hash->new;
$hash->store($key, $value);
my $value = $hash->fetch($key);

DESCRIPTION

Values are stored by reference and may be any kind of Obj.

CONSTRUCTORS

new

my $hash = Clownfish::Hash->new( capacity => 256 );

Return a new Hash.

  • capacity - The number of elements that the hash will be asked to hold initially.

METHODS

clear

$hash->clear();

Empty the hash of all key-value pairs.

store

$hash->store($key, $value);

Store a key-value pair.

fetch

$hash->fetch($key);

Fetch the value associated with key.

Returns: the value, or NULL if key is not present.

delete

$hash->delete($key);

Attempt to delete a key-value pair from the hash.

Returns: the value if key exists and thus deletion succeeds; otherwise NULL.

has_key

$hash->has_key($key);

Indicate whether the supplied key is present.

keys

$hash->keys();

Return a Vector of pointers to the hash’s keys.

values

$hash->values();

Return a Vector of pointers to the hash’s values.

get_size

$hash->get_size();

Return the number of key-value pairs.

INHERITANCE

Clownfish::Hash isa Clownfish::Obj.