forked from boostorg/range
Boost.Range documentation iteration.
[SVN r61660]
This commit is contained in:
@ -1,101 +0,0 @@
|
||||
<!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="adjacent_filtered"></a>
|
||||
<h4><code>adjacent_filtered</code></h4>
|
||||
<blockquote>
|
||||
<pre> rng | boost::adaptors::adjacent_filtered( bi_pred )
|
||||
</pre>
|
||||
<pre> boost::make_adjacent_filtered_range( rng, bi_pred )
|
||||
</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
The value-type of the range is convertible to both argument types
|
||||
of <code>bi_pred</code>.
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all adjacent elements <code>[x,y]</code> in the returned range,
|
||||
<code>bi_pred(x,y)</code> is <code>true</code>.
|
||||
</li>
|
||||
<li>
|
||||
<b>Throws:</b>
|
||||
Whatever the copy-constructor of bi_pred might throw.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
SinglePassRange
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/adjacent_filtered.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> <functional>
|
||||
<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::assign;
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
|
||||
std::vector<<span class="keyword">int</span>> input;
|
||||
input += 1,1,2,2,2,3,4,5,6;
|
||||
|
||||
boost::copy(
|
||||
input | adjacent_filtered(std::not_equal_to<<span class="keyword">int</span>>()),
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This would produce the output:<br />
|
||||
<code>1,2,3,4,5,6</code><br />
|
||||
</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>
|
||||
|
@ -1,93 +0,0 @@
|
||||
<!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="copied"></a>
|
||||
<h4><code>copied</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::copied( n, m )</pre>
|
||||
<pre>boost::make_copied_range( rng, n, m )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
<code>0 <= n && n <= m && m < distance(rng)</code>
|
||||
</li>
|
||||
<li>
|
||||
<b>Returns:</b>
|
||||
A new <code>iterator_range</code> that holds the sliced range
|
||||
<code>[n,m)</code> of the original range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
RandomAccessRange
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/copied.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::assign;
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
|
||||
std::vector<<span class="keyword">int</span>> input;
|
||||
input += 1,2,3,4,5,6,7,8,9,10;
|
||||
|
||||
boost::copy(
|
||||
input | copied(1, 5),
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This would produce the output:
|
||||
<code>2,3,4,5</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>
|
||||
|
@ -1,108 +0,0 @@
|
||||
<!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="filtered"></a>
|
||||
<h4><code>filtered</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::filtered( pred )</pre>
|
||||
<pre>boost::make_filtered_range( rng, pred )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
The value-type of the range is convertible to the argument type of
|
||||
<code>pred</code>.
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all elements <code>x</code> in the returned range,
|
||||
<code>pred(x)</code> is <code>true</code>
|
||||
</li>
|
||||
<li>
|
||||
<b>Throws:</b>
|
||||
Whatever the copy-constructor of pred might throw.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
ForwardRange
|
||||
</li>
|
||||
<li>
|
||||
<b>Returned Range Category:</b>
|
||||
ForwardRange
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/filtered.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">struct</span> is_even
|
||||
{
|
||||
<span class="keyword">bool operator</span>()(<span class="keyword">int</span> x) <span class="keyword">const</span> { <span class="keyword">return</span> x % 2 == 0; }
|
||||
};
|
||||
|
||||
<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::assign;
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
|
||||
std::vector<<span class="keyword">int</span>> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | filtered(is_even()),
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This would produce the output: <br />
|
||||
<code>2,4,6,8</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>
|
||||
|
@ -1,117 +0,0 @@
|
||||
<!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="indexed"></a>
|
||||
<h4><code>indexed</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::indexed</pre>
|
||||
<pre>boost::make_indexed_range( rng )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Returns:</b>
|
||||
A range adapted to return both the element and the associated
|
||||
index.
|
||||
The returned range consists of iterators that have in addition
|
||||
to the usual iterator member functions an
|
||||
<code>index()</code> member function that returns the appropriate
|
||||
index for the element in the sequence corresponding with the
|
||||
iterator.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
SinglePassRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/indexed.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">template</span><<span class="keyword">class</span> Iterator>
|
||||
void display_element_and_index(Iterator first, Iterator last)
|
||||
{
|
||||
<span class="keyword">for</span> (Iterator it = first; it != last; ++it)
|
||||
{
|
||||
std::cout << "Element = " << *it
|
||||
<< " Index = " << it.index() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
<span class="keyword">template</span><<span class="keyword">class</span> SinglePassRange>
|
||||
void display_element_and_index(<span class="keyword">const</span> SinglePassRange& rng)
|
||||
{
|
||||
display_element_and_index(boost::begin(rng), boost::end(rng));
|
||||
}
|
||||
|
||||
<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::assign;
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
|
||||
std::vector<<span class="keyword">int</span>> input;
|
||||
input += 10,20,30,40,50,60,70,80,90;
|
||||
|
||||
display_element_and_index( input | indexed(0) );
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
Element = 10 Index = 0 <br />
|
||||
Element = 20 Index = 1 <br />
|
||||
Element = 30 Index = 2 <br />
|
||||
Element = 40 Index = 3 <br />
|
||||
Element = 50 Index = 4 <br />
|
||||
Element = 60 Index = 5 <br />
|
||||
Element = 70 Index = 6 <br />
|
||||
Element = 80 Index = 7 <br />
|
||||
Element = 90 Index = 8 <br />
|
||||
</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>
|
||||
|
@ -1,95 +0,0 @@
|
||||
<!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="indirected"></a>
|
||||
<h4><code>indirected</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::indirected</pre>
|
||||
<pre>boost::make_indirected_range( rng )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
The value-type of the range defines unary <code>operator*()</code>
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all elements <code>x</code> in the returned range,
|
||||
<code>x</code> is the result of <code>*y</code> where
|
||||
<code>y</code> is the corresponding element in the original range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
SinglePassRange
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/indirected.hpp>
|
||||
<span class="keyword">#include</span> <boost/range/algorithm/copy.hpp>
|
||||
<span class="keyword">#include</span> <boost/shared_ptr.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;
|
||||
|
||||
std::vector<boost::shared_ptr<<span class="keyword">int</span>> > input;
|
||||
|
||||
<span class="keyword">for</span> (<span class="keyword">int</span> i = 0; i < 10; ++i)
|
||||
input.push_back(boost::shared_ptr<<span class="keyword">int</span>>(<span class="keyword">new int</span>(i)));
|
||||
|
||||
boost::copy(
|
||||
input | indirected,
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>0,1,2,3,4,5,6,7,8,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>
|
||||
|
@ -1,99 +0,0 @@
|
||||
<!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="map_keys"></a>
|
||||
<h4><code>map_keys</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::map_keys</pre>
|
||||
<pre>boost::make_map_key_range( rng )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
The value-type of the range is an instantiation of std::pair.
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all elements <code>x</code> in the returned range,
|
||||
<code>x</code> is the result of <code>y.first</code> where
|
||||
<code>y</code> is the corresponding element in the original range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
SinglePassRange
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/map.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> <map>
|
||||
<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::assign;
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
|
||||
std::map<<span class="keyword">int</span>,<span class="keyword">int</span>> input;
|
||||
<span class="keyword">for</span> (<span class="keyword">int</span> i = 0; i < 10; ++i)
|
||||
input.insert(std::make_pair(i, i * 10));
|
||||
|
||||
boost::copy(
|
||||
input | map_keys,
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
0,1,2,3,4,5,6,7,8,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>
|
||||
|
@ -1,98 +0,0 @@
|
||||
<!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="map_values"></a>
|
||||
<h4><code>map_values</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::map_values</pre>
|
||||
<pre>boost::make_map_value_range( rng )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
The value-type of the range is an instantiation of std::pair.
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all elements <code>x</code> in the returned range,
|
||||
<code>x</code> is the result of <code>y.second</code> where
|
||||
<code>y</code> is the corresponding element in the original range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
SinglePassRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/map.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> <map>
|
||||
<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::assign;
|
||||
<span class="keyword">using namespace</span> boost::adaptors;
|
||||
|
||||
std::map<<span class="keyword">int</span>,<span class="keyword">int</span>> input;
|
||||
<span class="keyword">for</span> (<span class="keyword">int</span> i = 0; i < 10; ++i)
|
||||
input.insert(std::make_pair(i, i * 10));
|
||||
|
||||
boost::copy(
|
||||
input | map_values,
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
0,10,20,30,40,50,60,70,80,90
|
||||
</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>
|
||||
|
@ -1,107 +0,0 @@
|
||||
<!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="replaced"></a>
|
||||
<h4><code>replaced</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::replaced( new_value, old_value )</pre>
|
||||
<pre>boost::make_replaced_range( rng, new_value, old_value )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
<ul>
|
||||
<li>
|
||||
<code>new_value</code> is convertible to the value-type of
|
||||
the range.
|
||||
</li>
|
||||
<li>
|
||||
<code>old_value</code> is convertible to the value-type of
|
||||
the range.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all elements <code>x</code> in the returned range, the value
|
||||
<code>x</code> is equal to the value of
|
||||
<code>(y == old_value) ? new_value : y</code>
|
||||
where <code>y</code> is the corresponding element in the original
|
||||
range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
ForwardRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/replaced.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,2,5,2,7,2,9;
|
||||
|
||||
boost::copy(
|
||||
input | replaced(2, 10),
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
1,10,3,10,5,10,7,10,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>
|
||||
|
@ -1,114 +0,0 @@
|
||||
<!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="replaced_if"></a>
|
||||
<h4><code>replaced_if</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::replaced_if( pred, new_value )</pre>
|
||||
<pre>boost::make_replaced_if_range( rng, pred, new_value )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
<ul>
|
||||
<li>
|
||||
The range value-type is convertible to the argument type
|
||||
of <code>pred</code>.
|
||||
</li>
|
||||
<li>
|
||||
<code>new_value</code> is convertible to the value-type
|
||||
of the range.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<b>Postconditions:</b>
|
||||
For all elements <code>[x]</code> in the returned range, the value
|
||||
<code>x</code> is equal to the value of
|
||||
<code>pred(y) ? new_value : y</code>
|
||||
where <code>y</code> is the corresponding element in the original
|
||||
range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
ForwardRange
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/replaced_if.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">struct</span> is_even
|
||||
{
|
||||
<span class="keyword">bool operator</span>()(<span class="keyword">int</span> x) <span class="keyword">const</span> { <span class="keyword">return</span> x % 2 == 0; }
|
||||
};
|
||||
|
||||
<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;
|
||||
|
||||
boost::copy(
|
||||
input | replaced_if(is_even(), 10),
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
1,10,3,10,5,10,7,10,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>
|
||||
|
@ -1,91 +0,0 @@
|
||||
<!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="reversed"></a>
|
||||
<h4><code>reversed</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::reversed</pre>
|
||||
<pre>boost::make_reversed_range( rng )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Returns:</b>
|
||||
A range whose iterators behave as if they were the original
|
||||
iterators wrapped in <code>reverse_iterator</code>.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
BidirectionalRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/reversed.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;
|
||||
|
||||
boost::copy(
|
||||
input | reversed,
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
9,8,7,6,5,4,3,2,1
|
||||
</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>
|
||||
|
@ -1,94 +0,0 @@
|
||||
<!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="sliced"></a>
|
||||
<h4><code>sliced</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::sliced( n, m )</pre>
|
||||
<pre>boost::make_sliced_range( rng, n, m )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
<code>0 <= n && n <= m && m < distance(rng)</code>
|
||||
</li>
|
||||
<li>
|
||||
<b>Returns:</b>
|
||||
<code>make_range(rng, n, m)</code>
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
RandomAccessRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/sliced.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;
|
||||
|
||||
boost::copy(
|
||||
input | sliced(2, 5),
|
||||
std::ostream_iterator<<span class="keyword">int</span>>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
3,4,5
|
||||
</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>
|
||||
|
@ -1,94 +0,0 @@
|
||||
<!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>
|
||||
|
@ -1,118 +0,0 @@
|
||||
<!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="tokenized"></a>
|
||||
<h4><code>tokenized</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::tokenized( regex )</pre>
|
||||
<pre>rng | boost::adaptors::tokenized( regex, i )</pre>
|
||||
<pre>rng | boost::adaptors::tokenized( regex, rndRng )</pre>
|
||||
<pre>rng | boost::adaptors::tokenized( regex, i, flags )</pre>
|
||||
<pre>rng | boost::adaptors::tokenized( regex, rndRng, flags )</pre>
|
||||
<pre>boost::make_tokenized_range( rng, regex, i, flags )</pre>
|
||||
<pre>boost::make_tokenized_range( rng, regex, rngRng, flags )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
<ul>
|
||||
<li>
|
||||
Let <code>T</code> denote
|
||||
<code>typename range_value< decltype(rng) >::type</code>,
|
||||
then <code>regex</code> has the type
|
||||
<code>basic_regex<T></code> or is
|
||||
implicitly convertible to one of these types.
|
||||
</li>
|
||||
<li>
|
||||
<code>i</code> has the type <code>int</code>.
|
||||
</li>
|
||||
<li>
|
||||
the value-type of <code>rndRng</code> is <code>int</code>.
|
||||
</li>
|
||||
<li>
|
||||
<code>flags</code> has the type
|
||||
<code>regex_constants::syntax_option_type</code>.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<b>Returns:</b>
|
||||
A range whose iterators behave as if they were the
|
||||
original iterators wrapped in <code>regex_token_iterator</code>.
|
||||
The first iterator in the range would be constructed by
|
||||
forwarding all the arguments of <code>tokenized()</code> to the
|
||||
<code>regex_token_iterator</code> constructor.
|
||||
</li>
|
||||
<li>
|
||||
<b>Throws:</b>
|
||||
Whatever constructing and copying equivalent
|
||||
<code>regex_token_iterator</code>s might throw.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
RandomAccessRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/tokenized.hpp>
|
||||
<span class="keyword">#include</span> <boost/range/algorithm_ext/push_back.hpp>
|
||||
<span class="keyword">#include</span> <boost/assert.hpp>
|
||||
<span class="keyword">#include</span> <algorithm>
|
||||
<span class="keyword">#include</span> <string>
|
||||
<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;
|
||||
|
||||
std::string input = "a b c d e f g hijklmnopqrstuvwxyz";
|
||||
std::vector< boost::sub_match< std::string::iterator > > result;
|
||||
boost::push_back(result, input | tokenized(boost::regex("\\b")));
|
||||
|
||||
BOOST_ASSERT( boost::size(result) == 16u );
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<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>
|
||||
|
@ -1,107 +0,0 @@
|
||||
<!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="transformed"></a>
|
||||
<h4><code>transformed</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::transformed( fun )</pre>
|
||||
<pre>boost::make_transformed_range( rng, fun )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
The value-type of the range is convertible to the argument type
|
||||
of fun.
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all elements <code>x</code> in the returned range,
|
||||
<code>x</code> is the result of <code>fun(y)</code> where
|
||||
<code>y</code> is the corresponding element in the original range.
|
||||
</li>
|
||||
<li>
|
||||
<b>Throws:</b>
|
||||
Whatever the copy-constructor of <code>fun</code> might throw.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
SinglePassRange
|
||||
</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
<pre>
|
||||
<span class="keyword">#include</span> <boost/range/adaptor/transformed.hpp>
|
||||
<span class="keyword">#include</span> <boost/range/algorithm/copy.hpp>
|
||||
<span class="keyword">#include</span> <boost/range/assign.hpp>
|
||||
<span class="keyword">#include</span> <algorithm>
|
||||
<span class="keyword">#include</span> <iostream>
|
||||
<span class="keyword">#include</span> <vector>
|
||||
|
||||
<span class="keyword">struct</span> double_int
|
||||
{
|
||||
<span class="keyword">typedef int</span> result_type;
|
||||
<span class="keyword">int operator</span>()(<span class="keyword">int</span> x) <span class="keyword">const</span> { <span class="keyword">return</span> x * 2; }
|
||||
};
|
||||
|
||||
<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 | transformed(double_int()),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
<span class="keyword">return</span> 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This produces the output: <br />
|
||||
<code>
|
||||
2,4,6,8,10,12,14,16,18,20
|
||||
</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>
|
||||
|
@ -1,95 +0,0 @@
|
||||
<!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="uniqued"></a>
|
||||
<h4><code>uniqued</code></h4>
|
||||
<blockquote>
|
||||
<pre>rng | boost::adaptors::uniqued</pre>
|
||||
<pre>boost::make_uniqued_range( rng )</pre>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Precondition:</b>
|
||||
The value-type of the range is comparable with
|
||||
<code>operator==()</code>.
|
||||
</li>
|
||||
<li>
|
||||
<b>Postcondition:</b>
|
||||
For all adjacent elements <code>[x,y]</code> in the returned range,
|
||||
<code>x==y</code> is false.
|
||||
</li>
|
||||
<li>
|
||||
<b>Range Category:</b>
|
||||
ForwardRange
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<h3>Example</h3>
|
||||
|
||||
<pre>
|
||||
#include <boost/range/adaptor/uniqued.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv)
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,1,2,2,2,3,4,5,6;
|
||||
|
||||
boost::copy(
|
||||
input | uniqued,
|
||||
std::ostream_iterator<int>(std::cout, ",") );
|
||||
|
||||
return 0;
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
This would produce the output:<br />
|
||||
<code>1,2,3,4,5,6</code><br />
|
||||
</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>
|
||||
|
@ -9,7 +9,7 @@
|
||||
* [*Precondition:] The `value_type` of the range is comparable with `operator==()`.
|
||||
* [*Postcondition:] For all adjacent elements `[x,y]` in the returned range, `x==y` is false.
|
||||
* [*Range Category:] __forward_range__
|
||||
* [*Returned Range Category:] The minimum of the range concept of `rng` and __bidirectional_range__.
|
||||
* [*Returned Range Category:] The minimum of the range concept of `rng` and __forward_pass_range__.
|
||||
|
||||
[section:uniqued_example uniqued example]
|
||||
``
|
||||
|
Reference in New Issue
Block a user