apr__ring_8h-source.html

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

HTML
502
字号
00162 <span class="comment">/**</span>
00163 <span class="comment"> * The first element of the ring</span>
00164 <span class="comment"> * @param hp   The head of the ring</span>
00165 <span class="comment"> */</span>
<a name="l00166"></a><a class="code" href="group__apr__ring.html#ga3">00166</a> <span class="preprocessor">#define APR_RING_FIRST(hp)      (hp)-&gt;next</span>
00167 <span class="preprocessor"></span><span class="comment">/**</span>
00168 <span class="comment"> * The last element of the ring</span>
00169 <span class="comment"> * @param hp   The head of the ring</span>
00170 <span class="comment"> */</span>
<a name="l00171"></a><a class="code" href="group__apr__ring.html#ga4">00171</a> <span class="preprocessor">#define APR_RING_LAST(hp)       (hp)-&gt;prev</span>
00172 <span class="preprocessor"></span><span class="comment">/**</span>
00173 <span class="comment"> * The next element in the ring</span>
00174 <span class="comment"> * @param ep   The current element</span>
00175 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00176 <span class="comment"> */</span>
<a name="l00177"></a><a class="code" href="group__apr__ring.html#ga5">00177</a> <span class="preprocessor">#define APR_RING_NEXT(ep, link) (ep)-&gt;link.next</span>
00178 <span class="preprocessor"></span><span class="comment">/**</span>
00179 <span class="comment"> * The previous element in the ring</span>
00180 <span class="comment"> * @param ep   The current element</span>
00181 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00182 <span class="comment"> */</span>
<a name="l00183"></a><a class="code" href="group__apr__ring.html#ga6">00183</a> <span class="preprocessor">#define APR_RING_PREV(ep, link) (ep)-&gt;link.prev</span>
00184 <span class="preprocessor"></span>
00185 <span class="comment"></span>
00186 <span class="comment">/**</span>
00187 <span class="comment"> * Initialize a ring</span>
00188 <span class="comment"> * @param hp   The head of the ring</span>
00189 <span class="comment"> * @param elem The name of the element struct</span>
00190 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00191 <span class="comment"> */</span>
<a name="l00192"></a><a class="code" href="group__apr__ring.html#ga7">00192</a> <span class="preprocessor">#define APR_RING_INIT(hp, elem, link) do {                              \</span>
00193 <span class="preprocessor">        APR_RING_FIRST((hp)) = APR_RING_SENTINEL((hp), elem, link);     \</span>
00194 <span class="preprocessor">        APR_RING_LAST((hp))  = APR_RING_SENTINEL((hp), elem, link);     \</span>
00195 <span class="preprocessor">    } while (0)</span>
00196 <span class="preprocessor"></span><span class="comment"></span>
00197 <span class="comment">/**</span>
00198 <span class="comment"> * Determine if a ring is empty</span>
00199 <span class="comment"> * @param hp   The head of the ring</span>
00200 <span class="comment"> * @param elem The name of the element struct</span>
00201 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00202 <span class="comment"> * @return true or false</span>
00203 <span class="comment"> */</span>
<a name="l00204"></a><a class="code" href="group__apr__ring.html#ga8">00204</a> <span class="preprocessor">#define APR_RING_EMPTY(hp, elem, link)                                  \</span>
00205 <span class="preprocessor">    (APR_RING_FIRST((hp)) == APR_RING_SENTINEL((hp), elem, link))</span>
00206 <span class="preprocessor"></span><span class="comment"></span>
00207 <span class="comment">/**</span>
00208 <span class="comment"> * Initialize a singleton element</span>
00209 <span class="comment"> * @param ep   The element</span>
00210 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00211 <span class="comment"> */</span>
<a name="l00212"></a><a class="code" href="group__apr__ring.html#ga9">00212</a> <span class="preprocessor">#define APR_RING_ELEM_INIT(ep, link) do {                               \</span>
00213 <span class="preprocessor">        APR_RING_NEXT((ep), link) = (ep);                               \</span>
00214 <span class="preprocessor">        APR_RING_PREV((ep), link) = (ep);                               \</span>
00215 <span class="preprocessor">    } while (0)</span>
00216 <span class="preprocessor"></span>
00217 <span class="comment"></span>
00218 <span class="comment">/**</span>
00219 <span class="comment"> * Splice the sequence ep1..epN into the ring before element lep</span>
00220 <span class="comment"> *   (..lep.. becomes ..ep1..epN..lep..)</span>
00221 <span class="comment"> * @warning This doesn't work for splicing before the first element or on</span>
00222 <span class="comment"> *   empty rings... see APR_RING_SPLICE_HEAD for one that does</span>
00223 <span class="comment"> * @param lep  Element in the ring to splice before</span>
00224 <span class="comment"> * @param ep1  First element in the sequence to splice in</span>
00225 <span class="comment"> * @param epN  Last element in the sequence to splice in</span>
00226 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00227 <span class="comment"> */</span>
<a name="l00228"></a><a class="code" href="group__apr__ring.html#ga10">00228</a> <span class="preprocessor">#define APR_RING_SPLICE_BEFORE(lep, ep1, epN, link) do {                \</span>
00229 <span class="preprocessor">        APR_RING_NEXT((epN), link) = (lep);                             \</span>
00230 <span class="preprocessor">        APR_RING_PREV((ep1), link) = APR_RING_PREV((lep), link);        \</span>
00231 <span class="preprocessor">        APR_RING_NEXT(APR_RING_PREV((lep), link), link) = (ep1);        \</span>
00232 <span class="preprocessor">        APR_RING_PREV((lep), link) = (epN);                             \</span>
00233 <span class="preprocessor">    } while (0)</span>
00234 <span class="preprocessor"></span><span class="comment"></span>
00235 <span class="comment">/**</span>
00236 <span class="comment"> * Splice the sequence ep1..epN into the ring after element lep</span>
00237 <span class="comment"> *   (..lep.. becomes ..lep..ep1..epN..)</span>
00238 <span class="comment"> * @warning This doesn't work for splicing after the last element or on</span>
00239 <span class="comment"> *   empty rings... see APR_RING_SPLICE_TAIL for one that does</span>
00240 <span class="comment"> * @param lep  Element in the ring to splice after</span>
00241 <span class="comment"> * @param ep1  First element in the sequence to splice in</span>
00242 <span class="comment"> * @param epN  Last element in the sequence to splice in</span>
00243 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00244 <span class="comment"> */</span>
<a name="l00245"></a><a class="code" href="group__apr__ring.html#ga11">00245</a> <span class="preprocessor">#define APR_RING_SPLICE_AFTER(lep, ep1, epN, link) do {                 \</span>
00246 <span class="preprocessor">        APR_RING_PREV((ep1), link) = (lep);                             \</span>
00247 <span class="preprocessor">        APR_RING_NEXT((epN), link) = APR_RING_NEXT((lep), link);        \</span>
00248 <span class="preprocessor">        APR_RING_PREV(APR_RING_NEXT((lep), link), link) = (epN);        \</span>
00249 <span class="preprocessor">        APR_RING_NEXT((lep), link) = (ep1);                             \</span>
00250 <span class="preprocessor">    } while (0)</span>
00251 <span class="preprocessor"></span><span class="comment"></span>
00252 <span class="comment">/**</span>
00253 <span class="comment"> * Insert the element nep into the ring before element lep</span>
00254 <span class="comment"> *   (..lep.. becomes ..nep..lep..)</span>
00255 <span class="comment"> * @warning This doesn't work for inserting before the first element or on</span>
00256 <span class="comment"> *   empty rings... see APR_RING_INSERT_HEAD for one that does</span>
00257 <span class="comment"> * @param lep  Element in the ring to insert before</span>
00258 <span class="comment"> * @param nep  Element to insert</span>
00259 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00260 <span class="comment"> */</span>
<a name="l00261"></a><a class="code" href="group__apr__ring.html#ga12">00261</a> <span class="preprocessor">#define APR_RING_INSERT_BEFORE(lep, nep, link)                          \</span>
00262 <span class="preprocessor">        APR_RING_SPLICE_BEFORE((lep), (nep), (nep), link)</span>
00263 <span class="preprocessor"></span><span class="comment"></span>
00264 <span class="comment">/**</span>
00265 <span class="comment"> * Insert the element nep into the ring after element lep</span>
00266 <span class="comment"> *   (..lep.. becomes ..lep..nep..)</span>
00267 <span class="comment"> * @warning This doesn't work for inserting after the last element or on</span>
00268 <span class="comment"> *   empty rings... see APR_RING_INSERT_TAIL for one that does</span>
00269 <span class="comment"> * @param lep  Element in the ring to insert after</span>
00270 <span class="comment"> * @param nep  Element to insert</span>
00271 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00272 <span class="comment"> */</span>
<a name="l00273"></a><a class="code" href="group__apr__ring.html#ga13">00273</a> <span class="preprocessor">#define APR_RING_INSERT_AFTER(lep, nep, link)                           \</span>
00274 <span class="preprocessor">        APR_RING_SPLICE_AFTER((lep), (nep), (nep), link)</span>
00275 <span class="preprocessor"></span>
00276 <span class="comment"></span>
00277 <span class="comment">/**</span>
00278 <span class="comment"> * Splice the sequence ep1..epN into the ring before the first element</span>
00279 <span class="comment"> *   (..hp.. becomes ..hp..ep1..epN..)</span>
00280 <span class="comment"> * @param hp   Head of the ring</span>
00281 <span class="comment"> * @param ep1  First element in the sequence to splice in</span>
00282 <span class="comment"> * @param epN  Last element in the sequence to splice in</span>
00283 <span class="comment"> * @param elem The name of the element struct</span>
00284 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00285 <span class="comment"> */</span>
<a name="l00286"></a><a class="code" href="group__apr__ring.html#ga14">00286</a> <span class="preprocessor">#define APR_RING_SPLICE_HEAD(hp, ep1, epN, elem, link)                  \</span>
00287 <span class="preprocessor">        APR_RING_SPLICE_AFTER(APR_RING_SENTINEL((hp), elem, link),      \</span>
00288 <span class="preprocessor">                             (ep1), (epN), link)</span>
00289 <span class="preprocessor"></span><span class="comment"></span>
00290 <span class="comment">/**</span>
00291 <span class="comment"> * Splice the sequence ep1..epN into the ring after the last element</span>
00292 <span class="comment"> *   (..hp.. becomes ..ep1..epN..hp..)</span>
00293 <span class="comment"> * @param hp   Head of the ring</span>
00294 <span class="comment"> * @param ep1  First element in the sequence to splice in</span>
00295 <span class="comment"> * @param epN  Last element in the sequence to splice in</span>
00296 <span class="comment"> * @param elem The name of the element struct</span>
00297 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00298 <span class="comment"> */</span>
<a name="l00299"></a><a class="code" href="group__apr__ring.html#ga15">00299</a> <span class="preprocessor">#define APR_RING_SPLICE_TAIL(hp, ep1, epN, elem, link)                  \</span>
00300 <span class="preprocessor">        APR_RING_SPLICE_BEFORE(APR_RING_SENTINEL((hp), elem, link),     \</span>
00301 <span class="preprocessor">                             (ep1), (epN), link)</span>
00302 <span class="preprocessor"></span><span class="comment"></span>
00303 <span class="comment">/**</span>
00304 <span class="comment"> * Insert the element nep into the ring before the first element</span>
00305 <span class="comment"> *   (..hp.. becomes ..hp..nep..)</span>
00306 <span class="comment"> * @param hp   Head of the ring</span>
00307 <span class="comment"> * @param nep  Element to insert</span>
00308 <span class="comment"> * @param elem The name of the element struct</span>
00309 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00310 <span class="comment"> */</span>
<a name="l00311"></a><a class="code" href="group__apr__ring.html#ga16">00311</a> <span class="preprocessor">#define APR_RING_INSERT_HEAD(hp, nep, elem, link)                       \</span>
00312 <span class="preprocessor">        APR_RING_SPLICE_HEAD((hp), (nep), (nep), elem, link)</span>
00313 <span class="preprocessor"></span><span class="comment"></span>
00314 <span class="comment">/**</span>
00315 <span class="comment"> * Insert the element nep into the ring after the last element</span>
00316 <span class="comment"> *   (..hp.. becomes ..nep..hp..)</span>
00317 <span class="comment"> * @param hp   Head of the ring</span>
00318 <span class="comment"> * @param nep  Element to insert</span>
00319 <span class="comment"> * @param elem The name of the element struct</span>
00320 <span class="comment"> * @param link The name of the APR_RING_ENTRY in the element struct</span>
00321 <span class="comment"> */</span>
<a name="l00322"></a><a class="code" href="group__apr__ring.html#ga17">00322</a> <span class="preprocessor">#define APR_RING_INSERT_TAIL(hp, nep, elem, link)                       \</span>
00323 <span class="preprocessor">        APR_RING_SPLICE_TAIL((hp), (nep), (nep), elem, link)</span>
00324 <span class="preprocessor"></span><span class="comment"></span>
00325 <span class="comment">/**</span>
00326 <span class="comment"> * Concatenate ring h2 onto the end of ring h1, leaving h2 empty.</span>
00327 <span class="comment"> * @param h1   Head of the ring to concatenate onto</span>
00328 <span class="comment"> * @param h2   Head of the ring to concatenate</span>
00329 <span class="comment"> * @param elem The name of the element struct</span>

⌨️ 快捷键说明

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