forked from boostorg/range
Boost.RangeEx merged into Boost.Range
[SVN r60897]
This commit is contained in:
1 parent
1461479a17
commit
b0d1db7c2e
471 files changed
+48610
-2065
No files matched your search
Executable
+94
@@ -0,0 +1,94 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Boost.Range Range Adaptors </title>
|
||||
<link rel="stylesheet" href="../style.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" >
|
||||
<tr>
|
||||
<td ><img src="../../../boost.png" border="0" /></td>
|
||||
<td ><h1 align="center">Boost.Range </h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2> Range Adaptors </h2>
|
||||
|
||||
<hr />
|
||||
<a name="strided"></a>
|
||||
<h4><code>strided</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::strided( n )</pre>
|
||||
<pre>boost::make_strided_range( rng, n )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
<code>0 <= n && n <= distance(rng)</code>
|
||||
</li>
|
||||
<li>
|
||||
<b>Returns:</b>
|
||||
A new range based on <code>rng</code> where traversal is performed in steps of <code>n</code>.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
RandomAccessRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/strided.hpp>
|
||||
<span class="keyword">#include</span> <boost/range/algorithm/copy.hpp>
|
||||
<span class="keyword">#include</span> <boost/assign.hpp>
|
||||
<span class="keyword">#include</span> <algorithm>
|
||||
<span class="keyword">#include</span> <iostream>
|
||||
<span class="keyword">#include</span> <vector>
|
||||
|
||||
<span class="keyword">int</span> main(<span class="keyword">int</span> argc, <span class="keyword">const char</span>* argv[])
|
||||
{
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
<span class="keyword">using namespace</span> boost::assign;
|
||||
|
||||
std::vector<<span class="keyword">int</span>> input;
|
||||
input += 1,2,3,4,5,6,7,8,9,10;
|
||||
|
||||
boost::copy(
|
||||
input | strided(2),
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output:
|
||||
<code>
|
||||
1,3,5,7,9
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<hr />
|
||||
<p>
|
||||
(C) Copyright Neil Groves 2009
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
</p>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in new issue
Block a user