NAME

src/pmc/orderedhash.pmc - OrderedHash PMC

DESCRIPTION

OrderedHash provide the interfaces of array and hash. Overall design heavily inspired by perl5 Tie::StoredOrderHash.

Some limitations:

To archive ordering for each item we store:

OrderedHash stores next things:

See t/pmc/orderedhash.t for test cases.

Methods

static PMC* get_list_item(PARROT_INTERP, PMC *self, INTVAL idx)
Get list_item by indexXXX Can this actually return NULL or not?
static void find_bounds(PARROT_INTERP, PMC *pmc_hash, PMC **first, PMC **last)
Find first/last in cloned/thawed OrderedHashParameter pmc_hash is Hash, not OrderedHash
static PMC* box_integer(PARROT_INTERP, INTVAL val)
Helper function to box INTVAL
static PMC* box_number(PARROT_INTERP, FLOATVAL val)
Helper function to box FLOATVAL
void init()
Create new instance of OrderedHash.
void mark()
Marks the OrderedHash as live.
PMC *get_iter()
Return a new iterator
INTVAL elements()
INTVAL get_integer()
FLOATVAL get_number()
Returns the size of the hash.
set_pmc_keyed(PMC *key, PMC *value)
Main set function.
void set_integer_keyed(INTVAL key, INTVAL value)
void set_number_keyed(INTVAL key, FLOATVAL value)
void set_string_keyed(INTVAL key, STRING *value)
Sets the PMC value of the element at index key to val.
void set_pmc_keyed_str(STRING *key, PMC *val)
Sets the PMC value of the element at index key to val.
PMC *get_pmc_keyed(PMC *key)
PMC *get_pmc_keyed_int(INTVAL key)
PMC *get_pmc_keyed_str(STRING *key)
STRING *get_string_keyed(PMC *key)
STRING *get_string_keyed_int(INTVAL key)
STRING *get_string_keyed_str(STRING *key)
INTVAL get_integer_keyed(PMC *key)
INTVAL get_integer_keyed_str(STRING *key)
INTVAL get_integer_keyed_int(INTVAL key)
Returns the integer value associated with key.
FLOATVAL get_number_keyed(PMC *key)
FLOATVAL get_number_keyed_int(INTVAL key)
FLOATVAL get_number_keyed_str(STRING *key)
Returns the floating-point value for the element at key.
void set_pmc_keyed_int(INTVAL idx, PMC *val)
void set_integer_keyed_int(INTVAL key, INTVAL value)
void set_number_keyed_int(INTVAL key, FLOATVAL value)
void set_string_keyed_int(INTVAL key, STRING *value)
Sets the PMC value of the element at index key to val. The created key = "\1idx".
void push_float(FLOATVAL value)
void push_integer(INTVAL value)
void push_pmc(PMC *value)
void push_string(STRING *value)
INTVAL exists_keyed(PMC *key)
INTVAL exists_keyed_str(STRING *key)
INTVAL exists_keyed_int(INTVAL key)
INTVAL defined_keyed(PMC *key)
INTVAL defined_keyed_int(INTVAL key)
void delete_keyed(PMC *key)
void delete_keyed_int(INTVAL key)
Deletes the key *key from the hash.
PMC *clone()
Create a clone of the OrderedHash. Non-existent keys are compacted. Accessing the clone via integers has different indices, if items were deleted.
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.
get_pmc()
Get underlying regular Hash. Used in UnManagedStruct.

SEE ALSO

docs/pdds/pdd08_keys.pod.