NAME

src/pmc/orderedhash.pmc - Ordered Hash

DESCRIPTION

OrderedHash extends Hash to provide the interfaces of array and hash. To achieve ordering, hash there are a few restrictions: delete_keyed never removes items; they are just nulled.

Please note that if values are set via integer idx, these indices have to be in strict order. Using push_xx simplifies this task. This creates a key "\1idx" for idx and is therefore not fully transparent.

There are two iterator interfaces:

See t/pmc/orderedhash.t.

Methods

void mark()
Marks the OrderedHash as live.
PMC *get_iter()
Return a new iterator
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_str(STRING *key)
INTVAL defined_keyed_int(INTVAL key)
void delete_keyed(PMC *key)
void delete_keyed_str(STRING *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(visit_info *info)
Used during archiving to visit the elements in the hash.
void freeze(visit_info *info)
Used to archive the hash.
void thaw(visit_info *info)
Used to unarchive the hash.Freeze/thaw are inherited from hash. Only thaw.visit is special, as we have to preserve key/value order.

SEE ALSO

docs/pdds/pdd08_keys.pod.

HISTORY

Initial rev by leo 2003-08-21.