1<html> 2 <head> 3 <meta content="text/html; charset=windows-1252" http-equiv="content-type"> 4 <title>sequences.html</title> 5 <link rel="stylesheet" type="text/css" href="../styles.css"> 6 </head> 7 <body> 8 <h4> Sequences </h4> 9 <div> A <i>sequence</i> (abbreviated to <i>seq</i>) is a group of adjacent 10 parenthesized elements. For example, </div> 11 <div class="code"> (<i>a</i>)(<i>b</i>)(<i>c</i>) </div> 12 <div> ...is a <i>seq</i> of <i>3</i> elements--<i>a</i>, <i>b</i>, and <i>c</i>. 13 </div> 14 <div> <i>Sequences</i> are data structures that merge the properties of 15 both <i>lists</i> and <i>tuples</i> with the exception that a <i>seq, </i>like 16 a <i>tuple, </i>cannot be empty. Therefore, an "empty" <i>seq</i> 17 is considered a special case scenario that must be handled separately in 18 C++. </div> 19 <div class="code"> 20 <pre>#define SEQ (x)(y)(z) 21#define REVERSE(s, state, elem) (elem) state 22 // append to head ^ 23 24BOOST_PP_SEQ_FOLD_LEFT(REVERSE, BOOST_PP_EMPTY, SEQ)() 25 // #1 #2 26 // 1) placeholder for "empty" seq 27 // 2) remove placeholder 28 29#define SEQ_B (1)(2)(3) 30#define INC(s, state, elem) state (BOOST_PP_INC(elem)) 31 // append to tail ^ 32 33BOOST_PP_SEQ_FOLD_RIGHT(INC, BOOST_PP_SEQ_NIL, SEQ) 34 // ^ 35 // special placeholder that will be "eaten" 36 // by appending to the tail 37</pre> </div> 38 <div> <i>Sequences</i> are extremely efficient. Element access speed 39 approaches random access--even with <i>seqs</i> of up to <i>256</i> 40 elements. This is because element access (among other things) is 41 implemented iteratively rather than recursively. Therefore, elements 42 can be accessed at extremely high indices even on preprocessors with low 43 maximum expansion depths. </div> 44 <div> Elements of a <i>seq</i> can be extracted with <b>BOOST_PP_SEQ_ELEM</b>. 45 </div> 46 <h4> Primitives </h4> 47 <ul> 48 <li> <a href="../ref/seq_elem.html">BOOST_PP_SEQ_ELEM</a></li> 49 </ul> 50 <hr size="1"> 51 <div style="margin-left: 0px;"> <i>� Copyright <a href="http://www.housemarque.com" 52 target="_top">Housemarque Oy</a> 2002</i> <br> 53 <i>� Copyright Paul Mensonides 2002</i> </div> 54 <div style="margin-left: 0px;"> 55 <p><small>Distributed under the Boost Software License, Version 1.0. (See 56 accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> 57 or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p> 58 </div> 59 </body> 60</html> 61