File: sequences.html

package info (click to toggle)
boost1.35 1.35.0-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 203,856 kB
  • ctags: 337,867
  • sloc: cpp: 938,683; xml: 56,847; ansic: 41,589; python: 18,999; sh: 11,566; makefile: 664; perl: 494; yacc: 456; asm: 353; csh: 6
file content (75 lines) | stat: -rw-r--r-- 2,496 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
	<head>
		<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> cannot be empty.&nbsp; 
			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.&nbsp; Element access speed approaches 
			random access--even with <i>seqs</i> of up to <i>256</i> elements.&nbsp; This 
			is because element access (among other things) is implemented iteratively 
			rather than recursively.&nbsp; 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>