The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 => $capacity,  # default: 0
    );

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

    my $obj = $hash->fetch($key);

Fetch the value associated with key.

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

delete

    my $obj = $hash->delete($key);

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

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

has_key

    my $bool = $hash->has_key($key);

Indicate whether the supplied key is present.

keys

    my $arrayref = $hash->keys();

Return the Hash’s keys.

values

    my $arrayref = $hash->values();

Return the Hash’s values.

get_size

    my $int = $hash->get_size();

Return the number of key-value pairs.

INHERITANCE

Clownfish::Hash isa Clownfish::Obj.