<!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> provide the interfaces of <code>array</code> and <code>hash</code>.</p> <p>Some limitations:</p> <ul> <li>Keys are always STRING*.</li> <li>Values are always PMC*.</li> </ul> <p>To archive ordering for each item we store:</p> <ul> <li><code>key</code></li> <p>Original key</p> <li><code>value</code></li> <p>Original value</p> <li><code>next</code></li> <p>Pointer to next <code>item</code></p> <li><code>prev</code></li> <p>Pointer to previous <code>item</code></p> </ul> <p>OrderedHash stores next things:</p> <ul> <li><code>hash</code></li> <p>Lookup hash for values.</p> <li><code>first</code></li> <p>Pointer to first inserted value.</p> <li><code>last</code></li> <p>Pointer to last inserter value.</p> </ul> <p>See <em>t/pmc/orderedhash.t</em> for test cases.</p> <p>Overall design heavily inspired by <code>Tie::StoredOrderHash</code>.</p> <h2><a name="Methods" >Methods</a></h2> <dl> <dt><a name="static_PMC*_get_list_item(PARROT_INTERP,_PMC_*self,_INTVAL_idx)" ><b><code>static PMC* get_list_item(PARROT_INTERP, PMC *self, INTVAL idx)</b></code></a></dt> Get list_item by indexXXX Can this actually return NULL or not? <dt><a name="static_void_find_bounds(PARROT_INTERP,_PMC_*pmc_hash,_PMC_**first,_PMC_**last)" ><b><code>static void find_bounds(PARROT_INTERP, PMC *pmc_hash, PMC **first, PMC **last)</b></code></a></dt> Find first/last in cloned/thawed OrderedHashParameter <code>pmc_hash</code> is Hash, not OrderedHash <dt><a name="static_PMC*_box_integer(PARROT_INTERP,_INTVAL_val)" ><b><code>static PMC* box_integer(PARROT_INTERP, INTVAL val)</b></code></a></dt> Helper function to box INTVAL <dt><a name="static_PMC*_box_number(PARROT_INTERP,_FLOATVAL_val)" ><b><code>static PMC* box_number(PARROT_INTERP, FLOATVAL val)</b></code></a></dt> Helper function to box FLOATVAL <dt><a name="void_init()" ><b><code>void init()</b></code></a></dt> Create new instance of OrderedHash. <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="INTVAL_elements()" ><b><code>INTVAL elements()</b></code></a></dt> <dt><a name="INTVAL_get_integer()" ><b><code>INTVAL get_integer()</b></code></a></dt> <dt><a name="FLOATVAL_get_number()" ><b><code>FLOATVAL get_number()</b></code></a></dt> Returns the size of the hash. <dt><a name="set_pmc_keyed(PMC_*key,_PMC_*value)" ><b><code>set_pmc_keyed(PMC *key, PMC *value)</b></code></a></dt> Main set function. <dt><a name="void_set_integer_keyed(INTVAL_key,_INTVAL_value)" ><b><code>void set_integer_keyed(INTVAL key, INTVAL value)</b></code></a></dt> <dt><a name="void_set_number_keyed(INTVAL_key,_FLOATVAL_value)" ><b><code>void set_number_keyed(INTVAL key, FLOATVAL value)</b></code></a></dt> <dt><a name="void_set_string_keyed(INTVAL_key,_STRING_*value)" ><b><code>void set_string_keyed(INTVAL key, STRING *value)</b></code></a></dt> Sets the PMC value of the element at index <code>key</code> to <code>val</code>. <dt><a name="void_set_pmc_keyed_str(STRING_*key,_PMC_*val)" ><b><code>void set_pmc_keyed_str(STRING *key, PMC *val)</b></code></a></dt> Sets the PMC value of the element at index <code>key</code> to <code>val</code>. <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_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_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(PMC_*info)" ><b><code>void visit(PMC *info)</b></code></a></dt> Used during archiving to visit the elements in the hash. <dt><a name="void_freeze(PMC_*info)" ><b><code>void freeze(PMC *info)</b></code></a></dt> Used to archive the hash. <dt><a name="void_thaw(PMC_*info)" ><b><code>void thaw(PMC *info)</b></code></a></dt> Used to unarchive the hash. <dt><a name="get_pmc()" ><b><code>get_pmc()</b></code></a></dt> Get underlying regular Hash. Used in UnManagedStruct.</dl> <h1><a name="SEE_ALSO" >SEE ALSO</a></h1> <p><em>docs/pdds/pdd08_keys.pod</em>.</p> </div> <!-- "mainbody" --> <div id="divider"></div> <div id="footer"> Copyright © 2002-2011, Parrot Foundation. </div> </div> <!-- "wrapper" --> </body> </html>