NAME

src/pmc/hash.pmc - Hash PMC

DESCRIPTION

Hash PMC wraps Parrot's _hash to provide a high-level API:

By default Hash uses string keys and PMC values. Methods set_key_type and set_value_type may be used to switch key and values type. For PMC keys hash value is calculated using VTABLE get_hashvalue function.

These are the vtable functions for the Hash PMC.

Functions

void init()
Initializes the instance.
void init_int(INTVAL value_type)
Initializes the instance with the value_type provided.
void destroy()
Free hash structure.
void mark()
Marks the hash as live.
PMC *clone()
Creates and returns a clone of the hash.
void set_pointer(void *ptr)
Use ptr as this PMC's Hash*.
void set_integer(INTVAL type)
void set_key_type(INTVAL type)
Reset Hash to use different keys. See enum Hash_key_type for possible values.NB: this method will destroy all old data!
METHOD get_key_type()
Return type of keys in Hash.
METHOD set_value_type(INTVAL type)
Reset Hash to use different value-type for stored items. If there is no previous _hash was set defaults to STRING* keys.NB: this method will destroy all old data!
void *get_pointer()
Get a pointer to this PMC's Hash*.
INTVAL get_integer()
FLOATVAL get_number()
Returns the size of the hash.
STRING *get_string()
Returns a string representation of the hash, showing its class name and memory address.
STRING *get_repr()
Return a representation of the hash contents.
INTVAL get_integer_keyed_str(STRING *key)
INTVAL get_integer_keyed_int(INTVAL key)
INTVAL get_integer_keyed(PMC *key)
Returns the integer value for the element at *key.
void set_integer_keyed(PMC *key, INTVAL value)
void set_integer_keyed_str(STRING *key, INTVAL value)
FLOATVAL get_number_keyed_str(STRING *key)
FLOATVAL get_number_keyed_int(INTVAL key)
FLOATVAL get_number_keyed(PMC *key)
Returns the floating-point value for the element at *key.
STRING *get_string_keyed_str(STRING *key)
STRING *get_string_keyed_int(INTVAL key)
STRING *get_string_keyed(PMC *key)
Returns the string value for the element at *key.
void set_string_keyed(PMC *key, STRING *value)
void set_string_keyed_str(STRING *key, STRING *value)
PMC *get_pmc_keyed(PMC *key)
PMC *get_pmc_keyed_str(STRING *key)
PMC *get_pmc_keyed_int(INTVAL key)
Returns the PMC value for the element at *key.
void set_number_keyed(PMC *key, FLOATVAL value)
void set_number_keyed_str(STRING *key, FLOATVAL value)
Sets value as the value for *key.
void set_pmc_keyed(PMC *dest_key, PMC *value)
void set_pmc_keyed_str(STRING *key, PMC *value)
Sets *value as the value for *key.
INTVAL exists_keyed_str(STRING *key)
INTVAL exists_keyed(PMC *key)
Returns whether a key *key exists in the hash.
INTVAL defined_keyed_str(STRING *key)
INTVAL defined_keyed(PMC *key)
Returns whether the value for *key is defined.
void delete_keyed_str(STRING *key)
void delete_keyed(PMC *key)
Deletes the element associated with *key.
INTVAL get_bool()
Returns true if the hash size is not zero.
INTVAL elements()
Returns the number of elements in the hash.
PMC *get_iter()
Return a new iterator.
INTVAL is_same(const PMC *other)
Returns whether the hash is the same as *other.
INTVAL is_equal(PMC *value)
The == operation.Check if two hashes hold the same keys and values.
PMC *slice(PMC *key)
Return a new iterator for the slice PMC key
void visit(PMC *info)
Used during archiving to visit the elements in the hash.
void freeze(PMC *info)
Used to archive the hash.
void thaw(PMC *info)
Used to unarchive the hash.

SEE ALSO

docs/pdds/pdd08_keys.pod.