123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <html>
- <head>
- <meta content="text/html; charset=windows-1252" http-equiv="content-type">
- <title>sequences.html</title>
- <link rel="stylesheet" type="text/css" href="../styles.css">
- </head>
- <body>
- <h4> Sequences </h4>
- <div> A <i>sequence</i> (abbreviated to <i>seq</i>) is a group of adjacent
- parenthesized elements. For example, </div>
- <div class="code"> (<i>a</i>)(<i>b</i>)(<i>c</i>) </div>
- <div> ...is a <i>seq</i> of <i>3</i> elements--<i>a</i>, <i>b</i>, and <i>c</i>.
- </div>
- <div> <i>Sequences</i> are data structures that merge the properties of
- both <i>lists</i> and <i>tuples</i> with the exception that a <i>seq, </i>like
- a <i>tuple, </i>cannot be empty. Therefore, an "empty" <i>seq</i>
- is considered a special case scenario that must be handled separately in
- C++. </div>
- <div class="code">
- <pre>#define SEQ (x)(y)(z)
- #define REVERSE(s, state, elem) (elem) state
- // append to head ^
- BOOST_PP_SEQ_FOLD_LEFT(REVERSE, BOOST_PP_EMPTY, SEQ)()
- // #1 #2
- // 1) placeholder for "empty" seq
- // 2) remove placeholder
- #define SEQ_B (1)(2)(3)
- #define INC(s, state, elem) state (BOOST_PP_INC(elem))
- // append to tail ^
- BOOST_PP_SEQ_FOLD_RIGHT(INC, BOOST_PP_SEQ_NIL, SEQ)
- // ^
- // special placeholder that will be "eaten"
- // by appending to the tail
- </pre> </div>
- <div> <i>Sequences</i> are extremely efficient. Element access speed
- approaches random access--even with <i>seqs</i> of up to <i>256</i>
- elements. This is because element access (among other things) is
- implemented iteratively rather than recursively. Therefore, elements
- can be accessed at extremely high indices even on preprocessors with low
- maximum expansion depths. </div>
- <div> Elements of a <i>seq</i> can be extracted with <b>BOOST_PP_SEQ_ELEM</b>.
- </div>
- <h4> Primitives </h4>
- <ul>
- <li> <a href="../ref/seq_elem.html">BOOST_PP_SEQ_ELEM</a></li>
- </ul>
- <hr size="1">
- <div style="margin-left: 0px;"> <i>© Copyright <a href="http://www.housemarque.com"
- target="_top">Housemarque Oy</a> 2002</i> <br>
- <i>© Copyright Paul Mensonides 2002</i> </div>
- <div style="margin-left: 0px;">
- <p><small>Distributed under the Boost Software License, Version 1.0. (See
- accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
- or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
- </div>
- </body>
- </html>
|