<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Parrot - Ordered Hash</title> <link rel="stylesheet" type="text/css" href="../../../resources/parrot.css" media="all"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <div id="wrapper"> <div id="header"> <a href="http://www.parrot.org"> <img border=0 src="../../../resources/parrot_logo.png" id="logo" alt="parrot"> </a> </div> <!-- "header" --> <div id="divider"></div> <div id="mainbody"> <div id="breadcrumb"> <a href="../../../html/index.html">Home</a> » <a href="../../../html/pmc.html">PMCs</a> » Ordered Hash </div> <h1><a name="NAME" >NAME</a></h1> <p>src/pmc/orderedhash.pmc - Ordered Hash</p> <h1><a name="DESCRIPTION" >DESCRIPTION</a></h1> <p><code>OrderedHash</code> extends <code>Hash</code> to provide the interfaces of <code>array</code> and <code>hash</code>. To achieve ordering, hash there are a few restrictions: <code>delete_keyed</code> never removes items; they are just nulled.</p> <p>Please note that if values are set via integer idx, these indices have to be in strict order. Using <code>push_xx</code> simplifies this task. This creates a key "\1idx" for <code>idx</code> and is therefore not fully transparent.</p> <p>There are two iterator interfaces:</p> <ul> <li>retrieve values (in creation order)</li> <p>Please note that after a <code>delete_keyed</code> operation, iterating over values doesn't work any more. You'll get an error 'No such key'.</p> <li>retrieve keys (in creation order)</li> </ul> <p>See <em><a href="../../t/pmc/orderedhash.t.html">t/pmc/orderedhash.t</a></em>.</p> <h2><a name="Methods" >Methods</a></h2> <dl> <dt><a name="void_mark()" ><b><code>void mark()</b></code></a></dt> Marks the OrderedHash as live. <dt><a name="PMC_*get_iter()" ><b><code>PMC *get_iter()</b></code></a></dt> Return a new iterator <dt><a name="PMC_*get_pmc_keyed(PMC_*key)" ><b><code>PMC *get_pmc_keyed(PMC *key)</b></code></a></dt> <dt><a name="PMC_*get_pmc_keyed_int(INTVAL_key)" ><b><code>PMC *get_pmc_keyed_int(INTVAL key)</b></code></a></dt> <dt><a name="PMC_*get_pmc_keyed_str(STRING_*key)" ><b><code>PMC *get_pmc_keyed_str(STRING *key)</b></code></a></dt> <dt><a name="STRING_*get_string_keyed(PMC_*key)" ><b><code>STRING *get_string_keyed(PMC *key)</b></code></a></dt> <dt><a name="STRING_*get_string_keyed_int(INTVAL_key)" ><b><code>STRING *get_string_keyed_int(INTVAL key)</b></code></a></dt> <dt><a name="STRING_*get_string_keyed_str(STRING_*key)" ><b><code>STRING *get_string_keyed_str(STRING *key)</b></code></a></dt> <dt><a name="INTVAL_get_integer_keyed(PMC_*key)" ><b><code>INTVAL get_integer_keyed(PMC *key)</b></code></a></dt> <dt><a name="INTVAL_get_integer_keyed_str(STRING_*key)" ><b><code>INTVAL get_integer_keyed_str(STRING *key)</b></code></a></dt> <dt><a name="INTVAL_get_integer_keyed_int(INTVAL_key)" ><b><code>INTVAL get_integer_keyed_int(INTVAL key)</b></code></a></dt> Returns the integer value associated with <code>key</code>. <dt><a name="FLOATVAL_get_number_keyed(PMC_*key)" ><b><code>FLOATVAL get_number_keyed(PMC *key)</b></code></a></dt> <dt><a name="FLOATVAL_get_number_keyed_int(INTVAL_key)" ><b><code>FLOATVAL get_number_keyed_int(INTVAL key)</b></code></a></dt> <dt><a name="FLOATVAL_get_number_keyed_str(STRING_*key)" ><b><code>FLOATVAL get_number_keyed_str(STRING *key)</b></code></a></dt> Returns the floating-point value for the element at <code>key</code>. <dt><a name="void_set_pmc_keyed_int(INTVAL_idx,_PMC_*val)" ><b><code>void set_pmc_keyed_int(INTVAL idx, PMC *val)</b></code></a></dt> <dt><a name="void_set_integer_keyed_int(INTVAL_key,_INTVAL_value)" ><b><code>void set_integer_keyed_int(INTVAL key, INTVAL value)</b></code></a></dt> <dt><a name="void_set_number_keyed_int(INTVAL_key,_FLOATVAL_value)" ><b><code>void set_number_keyed_int(INTVAL key, FLOATVAL value)</b></code></a></dt> <dt><a name="void_set_string_keyed_int(INTVAL_key,_STRING_*value)" ><b><code>void set_string_keyed_int(INTVAL key, STRING *value)</b></code></a></dt> Sets the PMC value of the element at index <code>key</code> to <code>val</code>. The created key = "\1idx". <dt><a name="void_push_float(FLOATVAL_value)" ><b><code>void push_float(FLOATVAL value)</b></code></a></dt> <dt><a name="void_push_integer(INTVAL_value)" ><b><code>void push_integer(INTVAL value)</b></code></a></dt> <dt><a name="void_push_pmc(PMC_*value)" ><b><code>void push_pmc(PMC *value)</b></code></a></dt> <dt><a name="void_push_string(STRING_*value)" ><b><code>void push_string(STRING *value)</b></code></a></dt> <dt><a name="INTVAL_exists_keyed(PMC_*key)" ><b><code>INTVAL exists_keyed(PMC *key)</b></code></a></dt> <dt><a name="INTVAL_exists_keyed_str(STRING_*key)" ><b><code>INTVAL exists_keyed_str(STRING *key)</b></code></a></dt> <dt><a name="INTVAL_exists_keyed_int(INTVAL_key)" ><b><code>INTVAL exists_keyed_int(INTVAL key)</b></code></a></dt> <dt><a name="INTVAL_defined_keyed(PMC_*key)" ><b><code>INTVAL defined_keyed(PMC *key)</b></code></a></dt> <dt><a name="INTVAL_defined_keyed_str(STRING_*key)" ><b><code>INTVAL defined_keyed_str(STRING *key)</b></code></a></dt> <dt><a name="INTVAL_defined_keyed_int(INTVAL_key)" ><b><code>INTVAL defined_keyed_int(INTVAL key)</b></code></a></dt> <dt><a name="void_delete_keyed(PMC_*key)" ><b><code>void delete_keyed(PMC *key)</b></code></a></dt> <dt><a name="void_delete_keyed_str(STRING_*key)" ><b><code>void delete_keyed_str(STRING *key)</b></code></a></dt> <dt><a name="void_delete_keyed_int(INTVAL_key)" ><b><code>void delete_keyed_int(INTVAL key)</b></code></a></dt> Deletes the key <code>*key</code> from the hash. <dt><a name="PMC_*clone()" ><b><code>PMC *clone()</b></code></a></dt> Create a clone of the OrderedHash. Non-existent keys are compacted. Accessing the clone via integers has different indices, if items were deleted. <dt><a name="void_visit(visit_info_*info)" ><b><code>void visit(visit_info *info)</b></code></a></dt> Used during archiving to visit the elements in the hash. <dt><a name="void_freeze(visit_info_*info)" ><b><code>void freeze(visit_info *info)</b></code></a></dt> Used to archive the hash. <dt><a name="void_thaw(visit_info_*info)" ><b><code>void thaw(visit_info *info)</b></code></a></dt> Used to unarchive the hash.Freeze/thaw are inherited from hash. Only thaw.visit is special, as we have to preserve key/value order.</dl> <h1><a name="SEE_ALSO" >SEE ALSO</a></h1> <p><em>docs/pdds/pdd08_keys.pod</em>.</p> <h1><a name="HISTORY" >HISTORY</a></h1> <p>Initial rev by leo 2003-08-21.</p> </div> <!-- "mainbody" --> <div id="divider"></div> <div id="footer"> Copyright © 2002-2009, Parrot Foundation. </div> </div> <!-- "wrapper" --> </body> </html>