apr__hash_8h-source.html

来自「apr函数库使用手册」· HTML 代码 · 共 238 行 · 第 1/2 页

HTML
238
字号
00113 <span class="comment"> * @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length.</span>
00114 <span class="comment"> * @return Returns NULL if the key is not present.</span>
00115 <span class="comment"> */</span>
00116 APR_DECLARE(<span class="keywordtype">void</span> *) apr_hash_get(apr_hash_t *ht, const <span class="keywordtype">void</span> *key,
00117                                  apr_ssize_t klen);
00118 <span class="comment"></span>
00119 <span class="comment">/**</span>
00120 <span class="comment"> * Start iterating over the entries in a hash table.</span>
00121 <span class="comment"> * @param p The pool to allocate the apr_hash_index_t iterator. If this</span>
00122 <span class="comment"> *          pool is NULL, then an internal, non-thread-safe iterator is used.</span>
00123 <span class="comment"> * @param ht The hash table</span>
00124 <span class="comment"> * @remark  There is no restriction on adding or deleting hash entries during</span>
00125 <span class="comment"> * an iteration (although the results may be unpredictable unless all you do</span>
00126 <span class="comment"> * is delete the current entry) and multiple iterations can be in</span>
00127 <span class="comment"> * progress at the same time.</span>
00128 <span class="comment"></span>
00129 <span class="comment"> * @example</span>
00130 <span class="comment"> */</span><span class="comment"></span>
00131 <span class="comment">/**</span>
00132 <span class="comment"> * &lt;PRE&gt;</span>
00133 <span class="comment"> * </span>
00134 <span class="comment"> * int sum_values(apr_pool_t *p, apr_hash_t *ht)</span>
00135 <span class="comment"> * {</span>
00136 <span class="comment"> *     apr_hash_index_t *hi;</span>
00137 <span class="comment"> *     void *val;</span>
00138 <span class="comment"> *     int sum = 0;</span>
00139 <span class="comment"> *     for (hi = apr_hash_first(p, ht); hi; hi = apr_hash_next(hi)) {</span>
00140 <span class="comment"> *         apr_hash_this(hi, NULL, NULL, &amp;val);</span>
00141 <span class="comment"> *         sum += *(int *)val;</span>
00142 <span class="comment"> *     }</span>
00143 <span class="comment"> *     return sum;</span>
00144 <span class="comment"> * }</span>
00145 <span class="comment"> * &lt;/PRE&gt;</span>
00146 <span class="comment"> */</span>
00147 APR_DECLARE(apr_hash_index_t *) apr_hash_first(apr_pool_t *p, apr_hash_t *ht);
00148 <span class="comment"></span>
00149 <span class="comment">/**</span>
00150 <span class="comment"> * Continue iterating over the entries in a hash table.</span>
00151 <span class="comment"> * @param hi The iteration state</span>
00152 <span class="comment"> * @return a pointer to the updated iteration state.  NULL if there are no more  </span>
00153 <span class="comment"> *         entries.</span>
00154 <span class="comment"> */</span>
00155 APR_DECLARE(apr_hash_index_t *) apr_hash_next(apr_hash_index_t *hi);
00156 <span class="comment"></span>
00157 <span class="comment">/**</span>
00158 <span class="comment"> * Get the current entry's details from the iteration state.</span>
00159 <span class="comment"> * @param hi The iteration state</span>
00160 <span class="comment"> * @param key Return pointer for the pointer to the key.</span>
00161 <span class="comment"> * @param klen Return pointer for the key length.</span>
00162 <span class="comment"> * @param val Return pointer for the associated value.</span>
00163 <span class="comment"> * @remark The return pointers should point to a variable that will be set to the</span>
00164 <span class="comment"> *         corresponding data, or they may be NULL if the data isn't interesting.</span>
00165 <span class="comment"> */</span>
00166 APR_DECLARE(<span class="keywordtype">void</span>) apr_hash_this(apr_hash_index_t *hi, const <span class="keywordtype">void</span> **key, 
00167                                 apr_ssize_t *klen, <span class="keywordtype">void</span> **val);
00168 <span class="comment"></span>
00169 <span class="comment">/**</span>
00170 <span class="comment"> * Get the number of key/value pairs in the hash table.</span>
00171 <span class="comment"> * @param ht The hash table</span>
00172 <span class="comment"> * @return The number of key/value pairs in the hash table.</span>
00173 <span class="comment"> */</span>
00174 APR_DECLARE(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>) apr_hash_count(apr_hash_t *ht);
00175 <span class="comment"></span>
00176 <span class="comment">/**</span>
00177 <span class="comment"> * Merge two hash tables into one new hash table. The values of the overlay</span>
00178 <span class="comment"> * hash override the values of the base if both have the same key.  Both</span>
00179 <span class="comment"> * hash tables must use the same hash function.</span>
00180 <span class="comment"> * @param p The pool to use for the new hash table</span>
00181 <span class="comment"> * @param overlay The table to add to the initial table</span>
00182 <span class="comment"> * @param base The table that represents the initial values of the new table</span>
00183 <span class="comment"> * @return A new hash table containing all of the data from the two passed in</span>
00184 <span class="comment"> */</span>
00185 APR_DECLARE(apr_hash_t *) apr_hash_overlay(apr_pool_t *p,
00186                                            const apr_hash_t *overlay, 
00187                                            const apr_hash_t *base);
00188 <span class="comment"></span>
00189 <span class="comment">/**</span>
00190 <span class="comment"> * Merge two hash tables into one new hash table. If the same key</span>
00191 <span class="comment"> * is present in both tables, call the supplied merge function to</span>
00192 <span class="comment"> * produce a merged value for the key in the new table.  Both</span>
00193 <span class="comment"> * hash tables must use the same hash function.</span>
00194 <span class="comment"> * @param p The pool to use for the new hash table</span>
00195 <span class="comment"> * @param h1 The first of the tables to merge</span>
00196 <span class="comment"> * @param h2 The second of the tables to merge</span>
00197 <span class="comment"> * @param merger A callback function to merge values, or NULL to</span>
00198 <span class="comment"> *  make values from h1 override values from h2 (same semantics as</span>
00199 <span class="comment"> *  apr_hash_overlay())</span>
00200 <span class="comment"> * @param data Client data to pass to the merger function</span>
00201 <span class="comment"> * @return A new hash table containing all of the data from the two passed in</span>
00202 <span class="comment"> */</span>
00203 APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p,
00204                                          const apr_hash_t *h1,
00205                                          const apr_hash_t *h2,
00206                                          <span class="keywordtype">void</span> * (*merger)(apr_pool_t *p,
00207                                                      const <span class="keywordtype">void</span> *key,
00208                                                      apr_ssize_t klen,
00209                                                      const <span class="keywordtype">void</span> *h1_val,
00210                                                      const <span class="keywordtype">void</span> *h2_val,
00211                                                      const <span class="keywordtype">void</span> *data),
00212                                          const <span class="keywordtype">void</span> *data);
00213 <span class="comment"></span>
00214 <span class="comment">/**</span>
00215 <span class="comment"> * Get a pointer to the pool which the hash table was created in</span>
00216 <span class="comment"> */</span>
00217 APR_POOL_DECLARE_ACCESSOR(hash);
00218 <span class="comment"></span>
00219 <span class="comment">/** @} */</span>
00220 
00221 #ifdef __cplusplus
00222 }
00223 #endif
00224 
00225 #endif  <span class="comment">/* !APR_HASH_H */</span>
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Mon Feb 7 13:18:25 2005 for Apache Portable Runtime by
<a href="../../../www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?