EVOLUTION-MANAGER
Edit File: cpl__hash__set_8h.html
<!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> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.5"/> <title>OGR: cpl_hash_set.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">OGR </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.5 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_651562d8bf6cfd3e81eff5b570d7df50.html">port</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">cpl_hash_set.h File Reference</div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><code>#include "<a class="el" href="cpl__port_8h_source.html">cpl_port.h</a>"</code><br/> </div> <p><a href="cpl__hash__set_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:ae6c1b105ee3fed90756691037ef20d24"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#ae6c1b105ee3fed90756691037ef20d24">CPLHashSetNew</a> (CPLHashSetHashFunc fnHashFunc, CPLHashSetEqualFunc fnEqualFunc, CPLHashSetFreeEltFunc fnFreeEltFunc)</td></tr> <tr class="separator:ae6c1b105ee3fed90756691037ef20d24"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a5895b1b1ba8eb2cc1698e27489ac7091"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#a5895b1b1ba8eb2cc1698e27489ac7091">CPLHashSetDestroy</a> (<a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> *set)</td></tr> <tr class="separator:a5895b1b1ba8eb2cc1698e27489ac7091"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a943eb087356353e5d3c06781cf7b7754"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#a943eb087356353e5d3c06781cf7b7754">CPLHashSetSize</a> (const <a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> *set)</td></tr> <tr class="separator:a943eb087356353e5d3c06781cf7b7754"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab50cf26e684b1c64dd3c978d3f802aa3"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#ab50cf26e684b1c64dd3c978d3f802aa3">CPLHashSetForeach</a> (<a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> *set, CPLHashSetIterEltFunc fnIterFunc, void *user_data)</td></tr> <tr class="separator:ab50cf26e684b1c64dd3c978d3f802aa3"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:aa28b8c9dfc8b8058f15c254cc0150f41"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#aa28b8c9dfc8b8058f15c254cc0150f41">CPLHashSetInsert</a> (<a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> *set, void *elt)</td></tr> <tr class="separator:aa28b8c9dfc8b8058f15c254cc0150f41"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a425b7a541a905456a010ee6f4bcf940f"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#a425b7a541a905456a010ee6f4bcf940f">CPLHashSetLookup</a> (<a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> *set, const void *elt)</td></tr> <tr class="separator:a425b7a541a905456a010ee6f4bcf940f"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a1898b26e58b2b3cd041f925e975c4d1a"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#a1898b26e58b2b3cd041f925e975c4d1a">CPLHashSetRemove</a> (<a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> *set, const void *elt)</td></tr> <tr class="separator:a1898b26e58b2b3cd041f925e975c4d1a"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a2ea4e15881139f7d5f10517b1489eea3"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#a2ea4e15881139f7d5f10517b1489eea3">CPLHashSetHashPointer</a> (const void *elt)</td></tr> <tr class="separator:a2ea4e15881139f7d5f10517b1489eea3"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a44adc3f09e064338676ea8f40077af03"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#a44adc3f09e064338676ea8f40077af03">CPLHashSetEqualPointer</a> (const void *elt1, const void *elt2)</td></tr> <tr class="separator:a44adc3f09e064338676ea8f40077af03"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:aa6c9878332d26a6071c9f6c552c4d69f"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#aa6c9878332d26a6071c9f6c552c4d69f">CPLHashSetHashStr</a> (const void *pszStr)</td></tr> <tr class="separator:aa6c9878332d26a6071c9f6c552c4d69f"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ae18034a787cae805266a85a21571649a"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="cpl__hash__set_8h.html#ae18034a787cae805266a85a21571649a">CPLHashSetEqualStr</a> (const void *pszStr1, const void *pszStr2)</td></tr> <tr class="separator:ae18034a787cae805266a85a21571649a"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Hash set implementation.</p> <p>An hash set is a data structure that holds elements that are unique according to a comparison function. Operations on the hash set, such as insertion, removal or lookup, are supposed to be fast if an efficient "hash" function is provided. </p> </div><h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="a5895b1b1ba8eb2cc1698e27489ac7091"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void CPLHashSetDestroy </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> * </td> <td class="paramname"><em>set</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Destroys an allocated hash set.</p> <p>This function also frees the elements if a free function was provided at the creation of the hash set.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">set</td><td>the hash set </td></tr> </table> </dd> </dl> <p>References <a class="el" href="cpl__list_8h.html#a1d19c7c63d51d57c7c7c6f6a236fca71">CPLListDestroy()</a>, <a class="el" href="struct__CPLList.html#aa64662b3d01669a7fb122dae52a1e232">_CPLList::pData</a>, and <a class="el" href="struct__CPLList.html#aac608a139b87b4a5a22b0e693c1f316e">_CPLList::psNext</a>.</p> </div> </div> <a class="anchor" id="a44adc3f09e064338676ea8f40077af03"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPLHashSetEqualPointer </td> <td>(</td> <td class="paramtype">const void * </td> <td class="paramname"><em>elt1</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const void * </td> <td class="paramname"><em>elt2</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Equality function for arbitrary pointers</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">elt1</td><td>the first arbitrary pointer to compare </td></tr> <tr><td class="paramname">elt2</td><td>the second arbitrary pointer to compare</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the pointers are equal </dd></dl> <p>Referenced by <a class="el" href="cpl__hash__set_8h.html#ae6c1b105ee3fed90756691037ef20d24">CPLHashSetNew()</a>.</p> </div> </div> <a class="anchor" id="ae18034a787cae805266a85a21571649a"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPLHashSetEqualStr </td> <td>(</td> <td class="paramtype">const void * </td> <td class="paramname"><em>elt1</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const void * </td> <td class="paramname"><em>elt2</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Equality function for strings</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">elt1</td><td>the first string to compare. May be NULL. </td></tr> <tr><td class="paramname">elt2</td><td>the second string to compare. May be NULL.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the strings are equal </dd></dl> </div> </div> <a class="anchor" id="ab50cf26e684b1c64dd3c978d3f802aa3"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void CPLHashSetForeach </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> * </td> <td class="paramname"><em>set</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">CPLHashSetIterEltFunc </td> <td class="paramname"><em>fnIterFunc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void * </td> <td class="paramname"><em>user_data</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Walk through the hash set and runs the provided function on all the elements</p> <p>This function is provided the user_data argument of CPLHashSetForeach. It must return TRUE to go on the walk through the hash set, or FALSE to make it stop.</p> <p>Note : the structure of the hash set must <em>NOT</em> be modified during the walk.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">set</td><td>the hash set. </td></tr> <tr><td class="paramname">fnIterFunc</td><td>the function called on each element. </td></tr> <tr><td class="paramname">user_data</td><td>the user data provided to the function. </td></tr> </table> </dd> </dl> <p>References <a class="el" href="struct__CPLList.html#aa64662b3d01669a7fb122dae52a1e232">_CPLList::pData</a>, and <a class="el" href="struct__CPLList.html#aac608a139b87b4a5a22b0e693c1f316e">_CPLList::psNext</a>.</p> </div> </div> <a class="anchor" id="a2ea4e15881139f7d5f10517b1489eea3"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">unsigned long CPLHashSetHashPointer </td> <td>(</td> <td class="paramtype">const void * </td> <td class="paramname"><em>elt</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Hash function for an arbitrary pointer</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">elt</td><td>the arbitrary pointer to hash</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the hash value of the pointer </dd></dl> <p>Referenced by <a class="el" href="cpl__hash__set_8h.html#ae6c1b105ee3fed90756691037ef20d24">CPLHashSetNew()</a>.</p> </div> </div> <a class="anchor" id="aa6c9878332d26a6071c9f6c552c4d69f"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">unsigned long CPLHashSetHashStr </td> <td>(</td> <td class="paramtype">const void * </td> <td class="paramname"><em>elt</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Hash function for a zero-terminated string</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">elt</td><td>the string to hash. May be NULL.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the hash value of the string </dd></dl> </div> </div> <a class="anchor" id="aa28b8c9dfc8b8058f15c254cc0150f41"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPLHashSetInsert </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> * </td> <td class="paramname"><em>set</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void * </td> <td class="paramname"><em>elt</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Inserts an element into a hash set.</p> <p>If the element was already inserted in the hash set, the previous element is replaced by the new element. If a free function was provided, it is used to free the previously inserted element</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">set</td><td>the hash set </td></tr> <tr><td class="paramname">elt</td><td>the new element to insert in the hash set</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the element was not already in the hash set </dd></dl> <p>References <a class="el" href="cpl__list_8h.html#a0ac887cca7e1a3ef9bac3f618c622f8a">CPLListInsert()</a>.</p> </div> </div> <a class="anchor" id="a425b7a541a905456a010ee6f4bcf940f"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void* CPLHashSetLookup </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> * </td> <td class="paramname"><em>set</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const void * </td> <td class="paramname"><em>elt</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Returns the element found in the hash set corresponding to the element to look up The element must not be modified.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">set</td><td>the hash set </td></tr> <tr><td class="paramname">elt</td><td>the element to look up in the hash set</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the element found in the hash set or NULL </dd></dl> </div> </div> <a class="anchor" id="ae6c1b105ee3fed90756691037ef20d24"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="struct__CPLHashSet.html">CPLHashSet</a>* CPLHashSetNew </td> <td>(</td> <td class="paramtype">CPLHashSetHashFunc </td> <td class="paramname"><em>fnHashFunc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">CPLHashSetEqualFunc </td> <td class="paramname"><em>fnEqualFunc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">CPLHashSetFreeEltFunc </td> <td class="paramname"><em>fnFreeEltFunc</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Creates a new hash set</p> <p>The hash function must return a hash value for the elements to insert. If fnHashFunc is NULL, CPLHashSetHashPointer will be used.</p> <p>The equal function must return if two elements are equal. If fnEqualFunc is NULL, CPLHashSetEqualPointer will be used.</p> <p>The free function is used to free elements inserted in the hash set, when the hash set is destroyed, when elements are removed or replaced. If fnFreeEltFunc is NULL, elements inserted into the hash set will not be freed.</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">fnHashFunc</td><td>hash function. May be NULL. </td></tr> <tr><td class="paramname">fnEqualFunc</td><td>equal function. May be NULL. </td></tr> <tr><td class="paramname">fnFreeEltFunc</td><td>element free function. May be NULL.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>a new hash set </dd></dl> <p>References <a class="el" href="cpl__conv_8h.html#a5b990672a0221115c9b54a8931554136">CPLCalloc()</a>, <a class="el" href="cpl__hash__set_8h.html#a44adc3f09e064338676ea8f40077af03">CPLHashSetEqualPointer()</a>, <a class="el" href="cpl__hash__set_8h.html#a2ea4e15881139f7d5f10517b1489eea3">CPLHashSetHashPointer()</a>, and <a class="el" href="cpl__conv_8h.html#a9ebcdb25fc6ff90b0c7b01733d5ae6d3">CPLMalloc()</a>.</p> </div> </div> <a class="anchor" id="a1898b26e58b2b3cd041f925e975c4d1a"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPLHashSetRemove </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> * </td> <td class="paramname"><em>set</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const void * </td> <td class="paramname"><em>elt</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Removes an element from a hash set</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">set</td><td>the hash set </td></tr> <tr><td class="paramname">elt</td><td>the new element to remove from the hash set</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>TRUE if the element was in the hash set </dd></dl> <p>References <a class="el" href="struct__CPLList.html#aa64662b3d01669a7fb122dae52a1e232">_CPLList::pData</a>, and <a class="el" href="struct__CPLList.html#aac608a139b87b4a5a22b0e693c1f316e">_CPLList::psNext</a>.</p> </div> </div> <a class="anchor" id="a943eb087356353e5d3c06781cf7b7754"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int CPLHashSetSize </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__CPLHashSet.html">CPLHashSet</a> * </td> <td class="paramname"><em>set</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Returns the number of elements inserted in the hash set</p> <p>Note: this is not the internal size of the hash set</p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">set</td><td>the hash set</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>the number of elements in the hash set </dd></dl> </div> </div> </div><!-- contents --> <hr> Generated for GDAL by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.8.5. </body> </html>