forked from boostorg/range
Boost.RangeEx merged into Boost.Range
[SVN r60897]
This commit is contained in:
205
doc/reference/adaptors.qbk
Normal file
205
doc/reference/adaptors.qbk
Normal file
@ -0,0 +1,205 @@
|
||||
[section:adaptors Range Adaptors]
|
||||
|
||||
[section:adaptors_introduction Introduction and motivation]
|
||||
|
||||
A [*Range Adaptor] is a class that wraps an existing Range to provide a new Range with different behaviour. Since the behaviour of Ranges is determined by their associated iterators, a Range Adaptor simply wraps the underlying iterators with new special iterators. In this example
|
||||
|
||||
``
|
||||
#include <boost/range/adaptors.hpp>
|
||||
#include <boost/range/algorithm.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
std::vector<int> vec;
|
||||
boost::copy( vec | boost::adaptors::reversed,
|
||||
std::ostream_iterator<int>(std::cout) );
|
||||
``
|
||||
|
||||
the iterators from `vec` are wrapped `reverse_iterator`s. The type of the underlying Range Adapter is not documented because you do not need to know it. All that is relevant is that the expression
|
||||
|
||||
``
|
||||
vec | boost::adaptors::reversed
|
||||
``
|
||||
|
||||
returns a Range Adaptor where the iterator type is now the iterator type of the range `vec` wrapped in `reverse_iterator`. The expression `boost::adaptors::reversed` is called an *Adaptor Generator*.
|
||||
|
||||
There are two ways of constructing a range adaptor. The first is by using `operator|()`. This is my preferred technique, however while discussing range adaptors with others it became clear that some users of the library strongly prefer a more familiar function syntax, so equivalent functions of the present tense form have been added as an alternative syntax. The equivalent to `rng | reversed` is `adaptors::reverse(rng)` for example.
|
||||
|
||||
Why do I prefer the `operator|` syntax? The answer is readability:
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::copy( boost::adaptors::reverse(vec),
|
||||
std::ostream_iterator<int>(std::cout) );
|
||||
``
|
||||
|
||||
This might not look so bad, but when we apply several adaptors, it becomes much worse. Just compare
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::copy( boost::adaptors::unique( boost::adaptors::reverse( vec ) ),
|
||||
std::ostream_iterator<int>(std::cout) );
|
||||
``
|
||||
|
||||
to
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::copy( vec | boost::adaptors::reversed
|
||||
| boost::adaptors::uniqued,
|
||||
std::ostream_iterator<int>(std::cout) );
|
||||
``
|
||||
|
||||
Furthermore, some of the adaptor generators take arguments themselves and these arguments are expressed with function call notation too. In those situations, you will really appreciate the succinctness of `operator|()`.
|
||||
|
||||
[heading Composition of Adaptors]
|
||||
|
||||
Range Adaptors are a powerful complement to Range algorithms. The reason is that adaptors are ['*orthogonal*] to algorithms. For example, consider these Range algorithms:
|
||||
|
||||
* `boost::copy( rng, out )`
|
||||
* `boost::count( rng, pred )`
|
||||
|
||||
What should we do if we only want to copy an element `a` if it satisfies some predicate, say `pred(a)`? And what if we only want to count the elements that satisfy the same predicate? The naive answer would be to use these algorithms:
|
||||
|
||||
* `boost::copy_if( rng, pred, out )`
|
||||
* `boost::count_if( rng, pred )`
|
||||
|
||||
These algorithms are only defined to maintain a one to one relationship with the standard library algorithms. This approach of adding algorithm suffers a combinatorial explosion. Inevitably many algorithms are missing `_if` variants and there is redundant development overhead for each new algorithm. The Adaptor Generator is the design solution to this problem.
|
||||
|
||||
[heading Range Adaptor alternative to copy_if algorithm]
|
||||
``
|
||||
boost::copy_if( rng, pred, out );
|
||||
``
|
||||
can be expressed as
|
||||
``
|
||||
boost::copy( rng | boost::adaptors::filtered(pred), out );
|
||||
``
|
||||
|
||||
[heading Range Adaptor alternative to count_if algorithm]
|
||||
``
|
||||
boost::count_if( rng, pred );
|
||||
``
|
||||
can be expressed as
|
||||
``
|
||||
boost::count( rng | boost::adaptors::filtered(pred), out );
|
||||
``
|
||||
|
||||
What this means is that ['*no*] algorithm with the `_if` suffix is needed. Furthermore, it turns out that algorithms with the `_copy` suffix are not needed either. Consider the somewhat misdesigned `replace_copy_if()` which may be used as
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::replace_copy_if( rng, std::back_inserter(vec), pred );
|
||||
``
|
||||
|
||||
With adaptors and algorithms we can express this as
|
||||
|
||||
``
|
||||
std::vector<int> vec;
|
||||
boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value));
|
||||
``
|
||||
|
||||
The latter code has several benefits:
|
||||
|
||||
1. it is more ['*efficient*] because we avoid extra allocations as might happen with `std::back_inserter`
|
||||
|
||||
2. it is ['*flexible*] as we can subsequently apply even more adaptors, for example: ``
|
||||
boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value)
|
||||
| boost::adaptors::reversed);
|
||||
``
|
||||
|
||||
3. it is ['*safer*] because there is no use of an unbounded output iterator.
|
||||
|
||||
In this manner, the ['*composition*] of Range Adaptors has the following consequences:
|
||||
|
||||
1. we no longer need `_if`, `_copy`, `_copy_if` and `_n` variants of algorithms.
|
||||
|
||||
2. we can generate a multitude of new algorithms on the fly, for example, above we generated `reverse_replace_copy_if()`
|
||||
|
||||
In other words:
|
||||
|
||||
[*Range Adaptors are to algorithms what algorithms are to containers]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:adaptors_synopsis Synopsis]
|
||||
|
||||
The library provides the following Adapter Generator expressions:
|
||||
|
||||
``
|
||||
rng | boost::adaptors::adjacent_filtered(bi_pred)
|
||||
rng | boost::adaptors::copied(n,m)
|
||||
rng | boost::adaptors::filtered(pred)
|
||||
rng | boost::adaptors::indexed
|
||||
rng | boost::adaptors::indirected
|
||||
rng | boost::adaptors::map_keys
|
||||
rng | boost::adaptors::map_values
|
||||
rng | boost::adaptors::replaced(new_value, old_value)
|
||||
rng | boost::adaptors::replaced_if(pred, new_value)
|
||||
rng | boost::adaptors::reversed
|
||||
rng | boost::adaptors::sliced(n, m)
|
||||
rng | boost::adaptors::strided(n)
|
||||
rng | boost::adaptors::tokenized( <see arguments below> )
|
||||
rng | boost::adaptors::transformed(fun)
|
||||
rng | boost::adaptors::uniqued
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:adaptors_general_requirements General Requirements]
|
||||
|
||||
In the description of generator expressions, the following notation is used:
|
||||
|
||||
* `fwdRng` is an expression of a type `R` that models `ForwardRange`
|
||||
* `biRng` is an expression of a type `R` that models `BidirectionalRange`
|
||||
* `rndRng` is an expression of a type `R` that models `RandomAccessRange`
|
||||
* `pred` is an expression of a type that models `UnaryPredicate`
|
||||
* `bi_pred` is an expression of a type that models `BinaryPredicate`
|
||||
* `fun` is an expression of a type that models `UnaryFunction`
|
||||
* `value`, `new_value` and `old_value` are objects convertible to `boost::range_value<R>::type`
|
||||
* `n,m` are integer expressions convertible to `range_difference<R>::type`
|
||||
|
||||
Also note that `boost::range_value<R>::type` must be implicitly convertible to the type arguments to `pred`, `bi_pred` and `fun`.
|
||||
|
||||
Range Category in the following adaptor descriptions refers to the minimum range concept required by the range passed to the adaptor. The resultant range is a model of the same range concept as the input range unless specified otherwise.
|
||||
|
||||
Returned Range Category is the concept of the returned range. In some cases the returned range is of a lesser category than the range passed to the adaptor. For example, the `filtered` adaptor returns only a `ForwardRange` regardless of the input.
|
||||
|
||||
Furthermore, the following rules apply to any expression of the form
|
||||
``
|
||||
rng | boost::adaptors::adaptor_generator
|
||||
``
|
||||
|
||||
1. Applying `operator|()` to a range `R` (always left argument) and a range adapter `RA` (always right argument) yields a new range type which may not conform to the same range concept as `R`.
|
||||
|
||||
2. The return-type of `operator|()` is otherwise unspecified.
|
||||
|
||||
3. `operator|()` is found by Argument Dependent Lookup (ADL) because a range adaptor is implemented in namespace `boost::adaptors`.
|
||||
|
||||
4. `operator|()` is used to add new behaviour ['*lazily*] and never modifies its left argument.
|
||||
|
||||
5. All iterators extracted from the left argument are extracted using qualified calls to `boost::begin()` and `boost::end()`.
|
||||
|
||||
6. In addition to the `throw`-clauses below, `operator|()` may throw exceptions as a result of copying iterators. If such copying cannot throw an exception, then neither can the whole expression.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:adaptors_reference Reference]
|
||||
[include adaptors/adjacent_filtered.qbk]
|
||||
[include adaptors/copied.qbk]
|
||||
[include adaptors/filtered.qbk]
|
||||
[include adaptors/indexed.qbk]
|
||||
[include adaptors/indirected.qbk]
|
||||
[include adaptors/map_keys.qbk]
|
||||
[include adaptors/map_values.qbk]
|
||||
[include adaptors/replaced.qbk]
|
||||
[include adaptors/replaced_if.qbk]
|
||||
[include adaptors/reversed.qbk]
|
||||
[include adaptors/sliced.qbk]
|
||||
[include adaptors/strided.qbk]
|
||||
[include adaptors/tokenized.qbk]
|
||||
[include adaptors/transformed.qbk]
|
||||
[include adaptors/uniqued.qbk]
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
101
doc/reference/adaptors/adjacent_filtered.html
Executable file
101
doc/reference/adaptors/adjacent_filtered.html
Executable file
@ -0,0 +1,101 @@
|
||||
<!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>
|
||||
|
47
doc/reference/adaptors/adjacent_filtered.qbk
Normal file
47
doc/reference/adaptors/adjacent_filtered.qbk
Normal file
@ -0,0 +1,47 @@
|
||||
[section:adjacent_filtered adjacent_filtered]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::adjacent_filtered(bi_pred)`]]
|
||||
[[Function] [`boost::adaptors::adjacent_filter(rng, bi_pred)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is convertible to both argument types of `bi_pred`.
|
||||
* [*Postcondition:] For all adjacent elements `[x,y]` in the returned range, `bi_pred(x,y)` is `true`.
|
||||
* [*Throws:] Whatever the copy constructor of `bi_pred` might throw.
|
||||
* [*Range Category:] `SinglePassRange`
|
||||
|
||||
[section:adjacent_filtered_example adjacent_filtered example]
|
||||
``
|
||||
#include <boost/range/adaptor/adjacent_filtered.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#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 | adjacent_filtered(std::not_equal_to<int>()),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,2,3,4,5,6
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
93
doc/reference/adaptors/copied.html
Executable file
93
doc/reference/adaptors/copied.html
Executable file
@ -0,0 +1,93 @@
|
||||
<!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>
|
||||
|
45
doc/reference/adaptors/copied.qbk
Normal file
45
doc/reference/adaptors/copied.qbk
Normal file
@ -0,0 +1,45 @@
|
||||
[section:copied copied]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::copied(n, m)`]]
|
||||
[[Function] [`boost::adaptors::copy(rng, n, m)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] `0 <= n && n <= m && m < distance(rng)`
|
||||
* [*Returns:] A new `iterator_range` that holds the sliced range `[n,m)` of the original range.
|
||||
* [*Range Category:] `RandomAccessRange`
|
||||
|
||||
[section:copied_example copied example]
|
||||
``
|
||||
#include <boost/range/adaptor/copied.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,2,3,4,5,6,7,8,9,10;
|
||||
|
||||
boost::copy(
|
||||
input | copied(1, 5),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
2,3,4,5
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
23
doc/reference/adaptors/examples/adjacent_filtered.cpp
Normal file
23
doc/reference/adaptors/examples/adjacent_filtered.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <boost/range/adaptor/adjacent_filtered.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <functinoal>
|
||||
#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 | adjacent_filtered(std::not_equal_to<int>()),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
22
doc/reference/adaptors/examples/copied.cpp
Normal file
22
doc/reference/adaptors/examples/copied.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <boost/range/adaptor/copied.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,2,3,4,5,6,7,8,9,10;
|
||||
|
||||
boost::copy(
|
||||
input | copied(1, 5),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
27
doc/reference/adaptors/examples/filtered.cpp
Normal file
27
doc/reference/adaptors/examples/filtered.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
struct is_even
|
||||
{
|
||||
bool operator()(int x) const { return x % 2 == 0; }
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | filtered(is_even()),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
36
doc/reference/adaptors/examples/indexed.cpp
Normal file
36
doc/reference/adaptors/examples/indexed.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include <boost/range/adaptor/indexed.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
template<typename Iterator>
|
||||
void display_element_and_index(Iterator first, Iterator last)
|
||||
{
|
||||
for (Iterator it = first; it != last; ++it)
|
||||
{
|
||||
std::cout << "Element = " << *it
|
||||
<< " Index = " << it.index() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename SinglePassRange>
|
||||
void display_element_and_index(const SinglePassRange& rng)
|
||||
{
|
||||
display_element_and_index(boost::begin(rng), boost::end(rng));
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 10,20,30,40,50,60,70,80,90;
|
||||
|
||||
display_element_and_index( input | indexed(0) );
|
||||
|
||||
return 0;
|
||||
]
|
||||
|
23
doc/reference/adaptors/examples/indirected.cpp
Normal file
23
doc/reference/adaptors/examples/indirected.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <boost/range/adaptor/indirected.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::vector<boost::shared_ptr<int> > input;
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
input.push_back(boost::shared_ptr<int>(new int(i)));
|
||||
|
||||
boost::copy(
|
||||
input | indirected,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
24
doc/reference/adaptors/examples/map_keys.cpp
Normal file
24
doc/reference/adaptors/examples/map_keys.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::map<int, int> input;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
input.insert(std::make_pair(i, i * 10));
|
||||
|
||||
boost::copy(
|
||||
input | map_keys,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
24
doc/reference/adaptors/examples/map_values.cpp
Normal file
24
doc/reference/adaptors/examples/map_values.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::map<int, int> input;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
input.insert(std::make_pair(i, i * 10));
|
||||
|
||||
boost::copy(
|
||||
input | map_values,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
22
doc/reference/adaptors/examples/replaced.cpp
Normal file
22
doc/reference/adaptors/examples/replaced.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <boost/range/adaptor/replaced.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::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,2,5,2,7,2,9;
|
||||
|
||||
boost::copy(
|
||||
input | replaced(2, 10),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
26
doc/reference/adaptors/examples/replaced_if.cpp
Normal file
26
doc/reference/adaptors/examples/replaced_if.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <boost/range/adaptor/replaced_if.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
struct is_even
|
||||
{
|
||||
bool operator()(int x) const { return x % 2 == 0; }
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | replaced_if(is_even(), 10),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
22
doc/reference/adaptors/examples/reversed.cpp
Normal file
22
doc/reference/adaptors/examples/reversed.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <boost/range/adaptor/reversed.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::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | reversed,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
22
doc/reference/adaptors/examples/sliced.cpp
Normal file
22
doc/reference/adaptors/examples/sliced.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <boost/range/adaptor/sliced.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::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | sliced(2, 5),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
22
doc/reference/adaptors/examples/strided.cpp
Normal file
22
doc/reference/adaptors/examples/strided.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <boost/range/adaptor/strided.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::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9,10;
|
||||
|
||||
boost::copy(
|
||||
input | strided(2),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
19
doc/reference/adaptors/examples/tokenized.cpp
Normal file
19
doc/reference/adaptors/examples/tokenized.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include <boost/range/adaptor/tokenized.hpp>
|
||||
#include <boost/range/algorithm_ext/push_back.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace 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 );
|
||||
|
||||
return 0;
|
||||
}
|
28
doc/reference/adaptors/examples/transformed.cpp
Normal file
28
doc/reference/adaptors/examples/transformed.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/range/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
struct double_int
|
||||
{
|
||||
typedef int result_type;
|
||||
int operator()(int x) const { return x * 2; }
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9,10;
|
||||
|
||||
boost::copy(
|
||||
input | transformed(double_int()),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
22
doc/reference/adaptors/examples/uniqued.cpp
Normal file
22
doc/reference/adaptors/examples/uniqued.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#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;
|
||||
}
|
||||
|
108
doc/reference/adaptors/filtered.html
Executable file
108
doc/reference/adaptors/filtered.html
Executable file
@ -0,0 +1,108 @@
|
||||
<!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>
|
||||
|
50
doc/reference/adaptors/filtered.qbk
Normal file
50
doc/reference/adaptors/filtered.qbk
Normal file
@ -0,0 +1,50 @@
|
||||
[section:filtered filtered]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::filtered(pred)`]]
|
||||
[[Function] [`boost::adaptors::filter(rng, pred)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is convertible to the argument type of `pred`.
|
||||
* [*Postcondition:] For all adjacent elements `[x]` in the returned range, `pred(x)` is `true`.
|
||||
* [*Throws:] Whatever the copy constructor of `pred` might throw.
|
||||
* [*Range Category:] `ForwardRange`
|
||||
* [*Returned Range Category:] `ForwardRange`
|
||||
|
||||
[section:filtered_example filtered example]
|
||||
``
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
struct is_even
|
||||
{
|
||||
bool operator()( int x ) const { return x % 2 == 0; }
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | filtered(is_even()),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
2,4,6,8
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
117
doc/reference/adaptors/indexed.html
Executable file
117
doc/reference/adaptors/indexed.html
Executable file
@ -0,0 +1,117 @@
|
||||
<!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>
|
||||
|
86
doc/reference/adaptors/indexed.qbk
Normal file
86
doc/reference/adaptors/indexed.qbk
Normal file
@ -0,0 +1,86 @@
|
||||
[section:indexed indexed]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::indexed`]]
|
||||
[[Function] [`boost::adaptors::index(rng)`]]
|
||||
]
|
||||
|
||||
* [*Returns:] 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 `index()` member function that returns the appropriate index for the element in the sequence corresponding with the iterator.
|
||||
* [*Range Category:] `SinglePassRange`
|
||||
|
||||
[section:indexed_example indexed example]
|
||||
``
|
||||
#include <boost/range/adaptor/indexed.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
template<class Iterator>
|
||||
void display_element_and_index(Iterator first, Iterator last)
|
||||
{
|
||||
for (Iterator it = first; it != last; ++it)
|
||||
{
|
||||
std::cout << "Element = " << *it << " Index = " << it.index() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
void display_element_and_index(const SinglePassRange& rng)
|
||||
{
|
||||
display_element_and_index(boost::begin(rng), boost::end(rng));
|
||||
}
|
||||
|
||||
template<class Iterator1, class Iterator2>
|
||||
void check_element_and_index(
|
||||
Iterator1 test_first,
|
||||
Iterator1 test_last,
|
||||
Iterator2 reference_first,
|
||||
Iterator2 reference_last)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( std::distance(test_first, test_last),
|
||||
std::distance(reference_first, reference_last) );
|
||||
|
||||
int reference_index = 0;
|
||||
|
||||
Iterator1 test_it = test_first;
|
||||
Iterator2 reference_it = reference_first;
|
||||
for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( *test_it, *reference_it );
|
||||
BOOST_CHECK_EQUAL( test_it.index(), reference_index );
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 10,20,30,40,50,60,70,80,90;
|
||||
|
||||
display_element_and_index( input | indexed(0) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
Element = 10 Index = 0
|
||||
Element = 20 Index = 1
|
||||
Element = 30 Index = 2
|
||||
Element = 40 Index = 3
|
||||
Element = 50 Index = 4
|
||||
Element = 60 Index = 5
|
||||
Element = 70 Index = 6
|
||||
Element = 80 Index = 7
|
||||
Element = 90 Index = 8
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
95
doc/reference/adaptors/indirected.html
Executable file
95
doc/reference/adaptors/indirected.html
Executable file
@ -0,0 +1,95 @@
|
||||
<!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>
|
||||
|
46
doc/reference/adaptors/indirected.qbk
Normal file
46
doc/reference/adaptors/indirected.qbk
Normal file
@ -0,0 +1,46 @@
|
||||
[section:indirected indirected]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::indirected`]]
|
||||
[[Function] [`boost::adaptors::indirect(rng)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range defines unary `operator*()`
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `*y` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] `SinglePassRange`
|
||||
|
||||
[section:indirected_example indirected example]
|
||||
``
|
||||
#include <boost/range/adaptor/indirected.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::vector<boost::shared_ptr<int> > input;
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
input.push_back(boost::shared_ptr<int>(new int(i)));
|
||||
|
||||
boost::copy(
|
||||
input | indirected,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
0,1,2,3,4,5,6,7,8,9
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
99
doc/reference/adaptors/map_keys.html
Executable file
99
doc/reference/adaptors/map_keys.html
Executable file
@ -0,0 +1,99 @@
|
||||
<!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>
|
||||
|
47
doc/reference/adaptors/map_keys.qbk
Normal file
47
doc/reference/adaptors/map_keys.qbk
Normal file
@ -0,0 +1,47 @@
|
||||
[section:map_keys map_keys]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::map_keys`]]
|
||||
[[Function] [`boost::adaptors::keys(rng)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is an instantiation of `std::pair`.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.first` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] `SinglePassRange`
|
||||
|
||||
[section:map_keys_example map_keys example]
|
||||
``
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::map<int,int> input;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
input.insert(std::make_pair(i, i * 10));
|
||||
|
||||
boost::copy(
|
||||
input | map_keys,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
0,1,2,3,4,5,6,7,8,9
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
98
doc/reference/adaptors/map_values.html
Executable file
98
doc/reference/adaptors/map_values.html
Executable file
@ -0,0 +1,98 @@
|
||||
<!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>
|
||||
|
47
doc/reference/adaptors/map_values.qbk
Normal file
47
doc/reference/adaptors/map_values.qbk
Normal file
@ -0,0 +1,47 @@
|
||||
[section:map_values map_values]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::map_values`]]
|
||||
[[Function] [`boost::adaptors::values(rng)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is an instantiation of `std::pair`.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.second` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] `SinglePassRange`
|
||||
|
||||
[section:map_values_example map_values example]
|
||||
``
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::assign;
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::map<int,int> input;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
input.insert(std::make_pair(i, i * 10));
|
||||
|
||||
boost::copy(
|
||||
input | map_values,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
0,10,20,30,40,50,60,70,80,90
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
107
doc/reference/adaptors/replaced.html
Executable file
107
doc/reference/adaptors/replaced.html
Executable file
@ -0,0 +1,107 @@
|
||||
<!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>
|
||||
|
47
doc/reference/adaptors/replaced.qbk
Normal file
47
doc/reference/adaptors/replaced.qbk
Normal file
@ -0,0 +1,47 @@
|
||||
[section:replaced replaced]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::replaced(new_value, old_value)`]]
|
||||
[[Function] [`boost::adaptors::replace(rng, new_value, old_value)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:]
|
||||
* `new_value` is convertible to the `value_type` of the range.
|
||||
* `old_value` is convertible to the `value_type` of the range.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, the value `x` is equal to the value of `(y == old_value) ? new_value : y` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] `ForwardRange`
|
||||
|
||||
[section:replaced_example replaced example]
|
||||
``
|
||||
#include <boost/range/adaptor/replaced.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::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,2,5,2,7,2,9;
|
||||
|
||||
boost::copy(
|
||||
input | replaced(2, 10),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,10,3,10,5,10,7,10,9
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
114
doc/reference/adaptors/replaced_if.html
Executable file
114
doc/reference/adaptors/replaced_if.html
Executable file
@ -0,0 +1,114 @@
|
||||
<!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>
|
||||
|
52
doc/reference/adaptors/replaced_if.qbk
Normal file
52
doc/reference/adaptors/replaced_if.qbk
Normal file
@ -0,0 +1,52 @@
|
||||
[section:replaced_if replaced_if]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::replaced_if(pred, new_value)`]]
|
||||
[[Function] [`boost::adaptors::replace_if(rng, pred, new_value)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:]
|
||||
* The range `value_type` is convertible to the argument type of `pred`.
|
||||
* `new_value` is convertible to the `value_type` of the range.
|
||||
* [*Postconditions:] For all elements `x` in the returned range, the value `x` is equal to the value of `pred(y) ? new_value : y` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] `ForwardRange`
|
||||
|
||||
[section:replaced_if_example replaced_if example]
|
||||
``
|
||||
#include <boost/range/adaptor/replaced_if.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
struct is_even
|
||||
{
|
||||
bool operator()(int x) const { return x % 2 == 0; }
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | replaced_if(is_even(), 10),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,10,3,10,5,10,7,10,9
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
91
doc/reference/adaptors/reversed.html
Executable file
91
doc/reference/adaptors/reversed.html
Executable file
@ -0,0 +1,91 @@
|
||||
<!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>
|
||||
|
44
doc/reference/adaptors/reversed.qbk
Normal file
44
doc/reference/adaptors/reversed.qbk
Normal file
@ -0,0 +1,44 @@
|
||||
[section:reversed reversed]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::reversed`]]
|
||||
[[Function] [`boost::adaptors::reverse(rng)`]]
|
||||
]
|
||||
|
||||
* [*Returns:] A range whose iterators behave as if they were the original iterators wrapped in `reverse_iterator`.
|
||||
* [*Range Category:] `BidirectionalRange`
|
||||
|
||||
[section:reversed_example reversed example]
|
||||
``
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
void reversed_example_test()
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | reversed,
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
9,8,7,6,5,4,3,2,1
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
94
doc/reference/adaptors/sliced.html
Executable file
94
doc/reference/adaptors/sliced.html
Executable file
@ -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="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>
|
||||
|
45
doc/reference/adaptors/sliced.qbk
Normal file
45
doc/reference/adaptors/sliced.qbk
Normal file
@ -0,0 +1,45 @@
|
||||
[section:sliced sliced]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::sliced(n, m)`]]
|
||||
[[Function] [`boost::adaptors::slice(rng, n, m)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] `0 <= n && n <= m && m < distance(rng)`
|
||||
* [*Returns:] `make_range(rng, n, m)`
|
||||
* [*Range Category:] `RandomAccessRange`
|
||||
|
||||
[section:sliced_example sliced example]
|
||||
``
|
||||
#include <boost/range/adaptor/sliced.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::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9;
|
||||
|
||||
boost::copy(
|
||||
input | sliced(2, 5),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
3,4,5
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
94
doc/reference/adaptors/strided.html
Executable file
94
doc/reference/adaptors/strided.html
Executable file
@ -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>
|
||||
|
45
doc/reference/adaptors/strided.qbk
Normal file
45
doc/reference/adaptors/strided.qbk
Normal file
@ -0,0 +1,45 @@
|
||||
[section:strided strided]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::strided(n)`]]
|
||||
[[Function] [`boost::adaptors::stride(rng, n)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] `0 <= n && n < distance(rng)`
|
||||
* [*Returns:] A new range based on `rng` where traversal is performed in steps of `n`.
|
||||
* [*Range Category:] `RandomAccessRange`
|
||||
|
||||
[section:strided_example strided example]
|
||||
``
|
||||
#include <boost/range/adaptor/strided.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::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9,10;
|
||||
|
||||
boost::copy(
|
||||
input | strided(2),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,3,5,7,9
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
118
doc/reference/adaptors/tokenized.html
Executable file
118
doc/reference/adaptors/tokenized.html
Executable file
@ -0,0 +1,118 @@
|
||||
<!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>
|
||||
|
42
doc/reference/adaptors/tokenized.qbk
Normal file
42
doc/reference/adaptors/tokenized.qbk
Normal file
@ -0,0 +1,42 @@
|
||||
[section:tokenized tokenized]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[
|
||||
[Pipe]
|
||||
[
|
||||
``
|
||||
rng | boost::adaptors::tokenized(regex)
|
||||
rng | boost::adaptors::tokenized(regex, i)
|
||||
rng | boost::adaptors::tokenized(regex, rndRng)
|
||||
rng | boost::adaptors::tokenized(regex, i, flags)
|
||||
rng | boost::adaptors::tokenized(regex, rndRng, flags)
|
||||
``
|
||||
]
|
||||
]
|
||||
[
|
||||
[Function]
|
||||
[
|
||||
``
|
||||
boost::adaptors::tokenize(rng, regex)
|
||||
boost::adaptors::tokenize(rng, regex, i)
|
||||
boost::adaptors::tokenize(rng, regex, rndRng)
|
||||
boost::adaptors::tokenize(rng, regex, i, flags)
|
||||
boost::adaptors::tokenize(rng, regex, rndRng, flags)
|
||||
``
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
* [*Precondition:]
|
||||
* Let `T` denote `typename range_value<decltype(rng)>::type`, then `regex` has the type `basic_regex<T>` or is implicitly convertible to one of these types.
|
||||
* `i` has the type `int`.
|
||||
* the `value_type` of `rndRng` is `int`.
|
||||
* `flags` has the type `regex_constants::syntax_option_type`.
|
||||
* [*Returns:] A range whose iterators behave as if they were the original iterators wrapped in `regex_token_iterator`. The first iterator in the range would be constructed by forwarding all the arguments of `tokenized()` to the `regex_token_iterator` constructor.
|
||||
* [*Throws:] Whatever constructing and copying equivalent `regex_token_iterator`s might throw.
|
||||
* [*Range Category:] `RandomAccessRange`
|
||||
|
||||
[endsect]
|
||||
|
||||
|
107
doc/reference/adaptors/transformed.html
Executable file
107
doc/reference/adaptors/transformed.html
Executable file
@ -0,0 +1,107 @@
|
||||
<!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>
|
||||
|
52
doc/reference/adaptors/transformed.qbk
Normal file
52
doc/reference/adaptors/transformed.qbk
Normal file
@ -0,0 +1,52 @@
|
||||
[section:transformed transformed]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::transformed(fun)`]]
|
||||
[[Function] [`boost::adaptors::transform(rng, fun)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:] The `value_type` of the range is convertible to the argument type of `fun`.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `fun(y)` where `y` is the corresponding element in the original range.
|
||||
* [*Throws:] Whatever the copy-constructor of `fun` might throw.
|
||||
* [*Range Category:] `SinglePassRange`
|
||||
|
||||
[section:transformed_example transformed example]
|
||||
``
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
struct double_int
|
||||
{
|
||||
typedef int result_type;
|
||||
int operator()(int x) const { return x * 2; }
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::vector<int> input;
|
||||
input += 1,2,3,4,5,6,7,8,9,10;
|
||||
|
||||
boost::copy(
|
||||
input | transformed(double_int()),
|
||||
std::ostream_iterator<int>(std::cout, ","));
|
||||
|
||||
return 0;
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
2,4,6,8,10,12,14,16,18,20
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
95
doc/reference/adaptors/uniqued.html
Executable file
95
doc/reference/adaptors/uniqued.html
Executable file
@ -0,0 +1,95 @@
|
||||
<!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>
|
||||
|
43
doc/reference/adaptors/uniqued.qbk
Normal file
43
doc/reference/adaptors/uniqued.qbk
Normal file
@ -0,0 +1,43 @@
|
||||
[section:uniqued uniqued]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::uniqued`]]
|
||||
[[Function] [`boost::adaptors::unique(rng)`]]
|
||||
]
|
||||
|
||||
* [*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:] `ForwardRange`
|
||||
|
||||
[section:uniqued_example uniqued example]
|
||||
``
|
||||
#include <boost/range/adaptor/uniqued.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
void uniqued_example_test()
|
||||
{
|
||||
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, ","));
|
||||
}
|
||||
``
|
||||
[endsect]
|
||||
|
||||
This would produce the output:
|
||||
``
|
||||
1,2,3,4,5,6
|
||||
``
|
||||
[endsect]
|
||||
|
||||
|
80
doc/reference/algorithm/adjacent_find.qbk
Normal file
80
doc/reference/algorithm/adjacent_find.qbk
Normal file
@ -0,0 +1,80 @@
|
||||
[section:adjacent_find Range Algorithm - adjacent_find]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
adjacent_find(ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
adjacent_find(const ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
adjacent_find(ForwardRange& rng, BinaryPred pred);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
adjacent_find(const ForwardRange& rng, BinaryPred pred);
|
||||
|
||||
template<range_return_value_re, class ForwardRange>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
adjacent_find(ForwardRange& rng);
|
||||
|
||||
template<range_return_value_re, class ForwardRange>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
adjacent_find(const ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
adjacent_find(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
adjacent_find(const ForwardRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
[*Non-predicate versions:]
|
||||
|
||||
`adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `x == y`
|
||||
|
||||
[*Predicate versions:]
|
||||
|
||||
`adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `pred(x,y)` is `true`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/adjacent_find.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions of adjacent_find:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange`'s value type is a model of the `EqualityComparableConcept`.
|
||||
|
||||
[*For the predicate versions of adjacent_find:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type and to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. If `empty(rng)` then no comparisons are performed; otherwise, at most `distance(rng) - 1` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
55
doc/reference/algorithm/binary_search.qbk
Normal file
55
doc/reference/algorithm/binary_search.qbk
Normal file
@ -0,0 +1,55 @@
|
||||
[section:binary_search binary_search]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Value>
|
||||
bool binary_search(const ForwardRange& rng, const Value& val);
|
||||
|
||||
template<class ForwardRange, class Value, class BinaryPredicate>
|
||||
bool binary_search(const ForwardRange& rng, const Value& val, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`binary_search` returns `true` if and only if the value `val` exists in the range `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/binary_search.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions of binary_search:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `Value` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
|
||||
[*For the predicate versions of binary_search:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s argument type.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
`rng` is ordered in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
`rng` is ordered in ascending order according to the function object `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
For non-random-access ranges, the complexity is `O(N)` where `N` is `distance(rng)`.
|
||||
|
||||
For random-access ranges, the complexity is `O(log N)` where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
36
doc/reference/algorithm/copy.qbk
Normal file
36
doc/reference/algorithm/copy.qbk
Normal file
@ -0,0 +1,36 @@
|
||||
[section:copy Range Algorithm - copy]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class OutputIterator>
|
||||
OutputIterator copy(const SinglePassRange& source_rng, OutputIterator out_it);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`copy` copies all elements from `source_rng` to the range `[out_it, out_it + distance(source_rng))`.
|
||||
The return value is `out_it + distance(source_rng)`
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/copy.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* The `value_type` of __single_pass_range__ Concept is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `out_it` is not an iterator within the `source_rng`.
|
||||
* `[out_it, out_it + distance(source_rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(source_rng)` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
41
doc/reference/algorithm/copy_backward.qbk
Normal file
41
doc/reference/algorithm/copy_backward.qbk
Normal file
@ -0,0 +1,41 @@
|
||||
[section:copy_backward Range Algorithm - copy_backward]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange, class BidirectionalOutputIterator>
|
||||
BidirectionalOutputIterator
|
||||
copy_backward(const BidirectionalRange& source_rng,
|
||||
BidirectionalOutputIterator out_it);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`copy_backward` copies all elements from `source_rng` to the range `[out_it - distance(source_rng), out_it)`.
|
||||
|
||||
The values are copied in reverse order. The return value is `out_it - distance(source_rng)`.
|
||||
|
||||
Note well that unlike all other standard algorithms `out_it` denotes the *end* of the output sequence.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/copy_backward.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `BidirectionalRange` is a model of __bidirectional_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* The `value_type` of __bidirectional_range__ Concept is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `out_it` is not an iterator within the `source_rng`.
|
||||
* `[out_it, out_it + distance(source_rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(source_rng)` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
36
doc/reference/algorithm/count.qbk
Normal file
36
doc/reference/algorithm/count.qbk
Normal file
@ -0,0 +1,36 @@
|
||||
[section:count count]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class Value>
|
||||
typename range_difference<SinglePassRange>::type
|
||||
count(SinglePassRange& rng, const Value& val);
|
||||
|
||||
template<class SinglePassRange, class Value>
|
||||
typename range_difference<const SinglePassRange>::type
|
||||
count(const SinglePassRange& rng, const Value& val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`count` returns the number of elements `x` in `rng` where `x == val` is `true`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/count.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `Value` is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* An object of `SinglePassRange`'s value type can be compared for equality with an object of type `Value`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
59
doc/reference/algorithm/equal.qbk
Normal file
59
doc/reference/algorithm/equal.qbk
Normal file
@ -0,0 +1,59 @@
|
||||
[section:equal equal]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2
|
||||
>
|
||||
bool equal(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
bool equal(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`equal` returns `true` if `distance(rng1)` is equal to the `distance(rng2)` and for each element `x` in `rng1`, the corresponding element `y` in `rng2` is equal. Otherwise `false` is returned.
|
||||
|
||||
In this range version of `equal` it is perfectly acceptable to pass in two ranges of unequal lengths.
|
||||
|
||||
Elements are considered equal in the non-predicate version if `operator==` returns `true`. Elements are considered equal in the predicate version if `pred(x,y)` is `true`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/equal.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange1`'s value type can be compared for equality with `SinglePassRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `min(distance(rng1), distance(rng2))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
78
doc/reference/algorithm/equal_range.qbk
Normal file
78
doc/reference/algorithm/equal_range.qbk
Normal file
@ -0,0 +1,78 @@
|
||||
[section:equal_range equal_range]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
std::pair<typename range_iterator<ForwardRange>::type,
|
||||
typename range_iterator<ForwardRange>::type>
|
||||
equal_range(ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
std::pair<typename range_iterator<const ForwardRange>::type,
|
||||
typename range_iterator<const ForwardRange>::type>
|
||||
equal_range(const ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value,
|
||||
class SortPredicate
|
||||
>
|
||||
std::pair<typename range_iterator<ForwardRange>::type,
|
||||
typename range_iterator<ForwardRange>::type>
|
||||
equal_range(ForwardRange& rng, const Value& val, SortPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value,
|
||||
class SortPredicate
|
||||
>
|
||||
std::pair<typename range_iterator<const ForwardRange>::type,
|
||||
typename range_iterator<const ForwardRange>::type>
|
||||
equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`equal_range` returns a range in the form of a pair of iterators where all of the elements are equal to `val`. If no values are found that are equal to `val`, then an empty range is returned, hence `result.first == result.second`. For the non-predicate versions of `equal_range` the equality of elements is determined by `operator<`.
|
||||
For the predicate versions of `equal_range` the equality of elements is determined by `pred`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/equal_range.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `Value` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `SortPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `ForwardRange`'s value type is the same as `Value`.
|
||||
* `ForwardRange`'s value type is convertible to both of `SortPredicate`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
For the non-predicate versions: `rng` is ordered in ascending order according to `operator<`.
|
||||
|
||||
For the predicate versions: `rng` is ordered in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
For random-access ranges, the complexity is `O(log N)`, otherwise the complexity is `O(N)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
34
doc/reference/algorithm/fill.qbk
Normal file
34
doc/reference/algorithm/fill.qbk
Normal file
@ -0,0 +1,34 @@
|
||||
[section:fill Range Algorithm - fill]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Value>
|
||||
void fill( ForwardRange& rng, const Value& val );
|
||||
|
||||
template<class ForwardRange, class Value>
|
||||
void fill( const ForwardRange& rng, const Value& val );
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`fill` assigns the value `val` to every element in the range `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/fill.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
52
doc/reference/algorithm/find.qbk
Normal file
52
doc/reference/algorithm/find.qbk
Normal file
@ -0,0 +1,52 @@
|
||||
[section:find find]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class Value>
|
||||
typename range_iterator<SinglePassRange>::type
|
||||
find(SinglePassRange& rng, Value val);
|
||||
|
||||
template<class SinglePassRange, class Value>
|
||||
typename range_iterator<const SinglePassRange>::type
|
||||
find(const SinglePassRange& rng, Value val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<SinglePassRange, re>::type
|
||||
find(SinglePassRange& rng, Value val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<const SinglePassRange, re>::type
|
||||
find(const SinglePassRange& rng, Value val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `find` that return an iterator, returns the first iterator in the range `rng` such that `*i == value`. `end(rng)` is returned if no such iterator exists.
|
||||
The versions of find that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/find.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `Value` is a model of the `EqualityComparableConcept`.
|
||||
* The `operator==` is defined for type `Value` to be compared with the `SinglePassRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng)` comparisons for equality.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
99
doc/reference/algorithm/find_end.qbk
Normal file
99
doc/reference/algorithm/find_end.qbk
Normal file
@ -0,0 +1,99 @@
|
||||
[section:find_end find_end]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange1, class ForwardRange2>
|
||||
typename range_iterator<ForwardRange1>::type
|
||||
find_end(ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<class ForwardRange1, class ForwardRange2>
|
||||
typename range_iterator<const ForwardRange1>::type
|
||||
find_end(const ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange1>::type
|
||||
find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<const ForwardRange1>::type
|
||||
find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<ForwardRange1, re>::type
|
||||
find_end(ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<const ForwardRange1, re>::type
|
||||
find_end(const ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange1, re>::type
|
||||
find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange1, re>::type
|
||||
find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `find_end` that return an iterator, return an iterator to the beginning of the last sub-sequence equal to `rng2` within `rng1`.
|
||||
Equality is determined by `operator==` for non-predicate versions of `find_end`, and by satisfying `pred` in the predicate versions. The versions of `find_end` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/find_end.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange1` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange1`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `ForwardRange2`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* Objects of `ForwardRange1`'s value type can be compared for equality with objects of `ForwardRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange1` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
The number of comparisons is proportional to `distance(rng1) * distance(rng2)`. If both `ForwardRange1` and `ForwardRange2` are models of `BidirectionalRangeConcept` then the average complexity is linear and the worst case is `distance(rng1) * distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
99
doc/reference/algorithm/find_first_of.qbk
Normal file
99
doc/reference/algorithm/find_first_of.qbk
Normal file
@ -0,0 +1,99 @@
|
||||
[section:find_first_of find_first_of]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange1, class ForwardRange2>
|
||||
typename range_iterator<SinglePassRange1>::type
|
||||
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<class SinglePassRange1, class ForwardRange2>
|
||||
typename range_iterator<const SinglePassRange1>::type
|
||||
find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<SinglePassRange1>::type
|
||||
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<const SinglePassRange1>::type
|
||||
find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<SinglePassRange1, re>::type
|
||||
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<const SinglePassRange1, re>::type
|
||||
find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<SinglePassRange1, re>::type
|
||||
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const SinglePassRange1, re>::type
|
||||
find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `find_first_of` that return an iterator, return an iterator to the first occurrence in `rng1` of any of the elements in `rng2`.
|
||||
Equality is determined by `operator==` for non-predicate versions of `find_first_of`, and by satisfying `pred` in the predicate versions.
|
||||
|
||||
The versions of `find_first_of` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/find_first_of.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`, and can be compared for equality with `ForwardRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
At most `distance(rng1) * distance(rng2)` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
57
doc/reference/algorithm/find_if.qbk
Normal file
57
doc/reference/algorithm/find_if.qbk
Normal file
@ -0,0 +1,57 @@
|
||||
[section:find_if find_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange, class UnaryPredicate>
|
||||
typename range_iterator<SinglePassRange>::type
|
||||
find_if(SinglePassRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<class SinglePassRange, class UnaryPredicate>
|
||||
typename range_iterator<const SinglePassRange>::type
|
||||
find_if(const SinglePassRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<SinglePassRange, re>::type
|
||||
find_if(SinglePassRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class SinglePassRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<const SinglePassRange, re>::type
|
||||
find_if(const SinglePassRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `find_if` that return an iterator, returns the first iterator in the range `rng` such that `pred(*i)` is `true`. `end(rng)` is returned if no such iterator exists.
|
||||
|
||||
The versions of `find_if` that return a `range_return`, defines found in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/find_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`.
|
||||
* The value type of `SinglePassRange` is convertible to the argument type of `UnaryPredicate`.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
For each iterator `i` in `rng`, `*i` is in the domain of `UnaryPredicate`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng)` invocations of `pred`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
40
doc/reference/algorithm/for_each.qbk
Normal file
40
doc/reference/algorithm/for_each.qbk
Normal file
@ -0,0 +1,40 @@
|
||||
[section:for_each for_each]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange,
|
||||
class UnaryFunction
|
||||
>
|
||||
UnaryFunction for_each(SinglePassRange& rng, UnaryFunction fun);
|
||||
|
||||
template<
|
||||
class SinglePassRange,
|
||||
class UnaryFunction
|
||||
>
|
||||
UnaryFunction for_each(const SinglePassRange& rng, UnaryFunction fun);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`for_each` traverses forward through `rng` and for each element `x` it invokes `fun(x)`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/for_each.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
* `UnaryFunction` is a model of the `UnaryFunctionConcept`.
|
||||
* `UnaryFunction` does not apply any non-constant operation through its argument.
|
||||
* `SinglePassRange`'s value type is convertible to `UnaryFunction`'s argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` applications of `UnaryFunction`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
39
doc/reference/algorithm/generate.qbk
Normal file
39
doc/reference/algorithm/generate.qbk
Normal file
@ -0,0 +1,39 @@
|
||||
[section:generate Range Algorithm - generate]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Generator>
|
||||
ForwardRange& generate( ForwardRange& rng, Generator gen );
|
||||
|
||||
template<class ForwardRange, class Generator>
|
||||
const ForwardRange& generate( const ForwardRange& rng, Generator gen );
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`generate` assigns the result of `gen()` to each element in range `rng`. Returns the resultant range.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/generate.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Generator` is a model of the `GeneratorConcept`.
|
||||
* The `value_type` of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `out_it` is not an iterator within `rng`.
|
||||
* `[out_it, out_it + distance(rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` assignments are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
64
doc/reference/algorithm/includes.qbk
Normal file
64
doc/reference/algorithm/includes.qbk
Normal file
@ -0,0 +1,64 @@
|
||||
[section:includes includes]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`includes` returns `true` if and only if, for every element in `rng2`, an equivalent element is also present in `rng1`.
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
72
doc/reference/algorithm/inplace_merge.qbk
Normal file
72
doc/reference/algorithm/inplace_merge.qbk
Normal file
@ -0,0 +1,72 @@
|
||||
[section:inplace_merge Range Algorithm - inplace_merge]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange>
|
||||
BidirectionalRange&
|
||||
inplace_merge( BidirectionalRange& rng,
|
||||
typename range_iterator<BidirectionalRange>::type middle );
|
||||
|
||||
template<class BidirectionalRange>
|
||||
const BidirectionalRange&
|
||||
inplace_merge( const BidirectionalRange& rng,
|
||||
typename range_iterator<const BidirectionalRange>::type middle );
|
||||
|
||||
template<class BidirectionalRange, class BinaryPredicate>
|
||||
BidirectionalRange&
|
||||
inplace_merge( BidirectionalRange& rng,
|
||||
typename range_iterator<BidirectionalRange>::type middle,
|
||||
BinaryPredicate pred );
|
||||
|
||||
template<class BidirectionalRange, class BinaryPredicate>
|
||||
const BidirectionalRange&
|
||||
inplace_merge( const BidirectionalRange& rng,
|
||||
typename range_iterator<const BidirectionalRange>::type middle,
|
||||
BinaryPredicate pred );
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`inplace_merge` combines two consecutive sorted ranges `[begin(rng), middle)` and `[middle, end(rng))` into a single sorted range `[begin(rng), end(rng))`. That is, it starts with a range `[begin(rng), end(rng))` that consists of two pieces each of which is in ascending order, and rearranges it so that the entire range is in ascending order. `inplace_merge` is stable, meaning both that the relative order of elements within each input range is preserved.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/inplace_merge.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `range_value<BidirectionalRange>::type` is a model of `LessThanComparableConcept`
|
||||
* The ordering on objects of `range_type<BidirectionalRange>::type` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate version:]
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `BidirectionalRange`'s value type is convertible to both `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[heading For the non-predicate version:]
|
||||
|
||||
* `middle` is in the range `rng`.
|
||||
* `[begin(rng), middle)` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `y < x` is `false`.
|
||||
* `[middle, end(rng))` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `y < x` is `false`.
|
||||
|
||||
[heading For the predicate version:]
|
||||
|
||||
* `middle` is in the range `rng`.
|
||||
* `[begin(rng), middle)` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `pred(y,x) == false`.
|
||||
* `[middle, end(rng))` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `pred(y,x) == false`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Worst case: `O(N log(N))`
|
||||
|
||||
[endsect]
|
||||
|
||||
|
55
doc/reference/algorithm/lexicographical_compare.qbk
Normal file
55
doc/reference/algorithm/lexicographical_compare.qbk
Normal file
@ -0,0 +1,55 @@
|
||||
[section:lexicographical_compare lexicographical_compare]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2
|
||||
>
|
||||
bool lexicographical_compare(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
bool lexicographical_compare(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`lexicographical_compare` compares element by element `rng1` against `rng2`. If the element from `rng1` is less than the element from `rng2` then `true` is returned. If the end of `rng1` without reaching the end of `rng2` this also causes the return value to be `true`. The return value is `false` in all other circumstances. The elements are compared using `operator<` in the non-predicate versions of `lexicographical_compare` and using `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/lexicographical_compare.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions of lexicographical_compare:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* Let `x` be an object of `SinglePassRange1`'s value type. Let `y` be an obect of `SinglePassRange2`'s value type. `x < y` must be valid. `y < x` must be valid.
|
||||
|
||||
[*For the predicate versions of lexicographical_compare:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `2 * min(distance(rng1), distance(rng2))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
80
doc/reference/algorithm/lower_bound.qbk
Normal file
80
doc/reference/algorithm/lower_bound.qbk
Normal file
@ -0,0 +1,80 @@
|
||||
[section:lower_bound lower_bound]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Value>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
lower_bound(ForwardRange& rng, Value val);
|
||||
|
||||
template<class ForwardRange, class Value>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
lower_bound(const ForwardRange& rng, Value val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
lower_bound(ForwardRange& rng, Value val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
lower_bound(const ForwardRange& rng, Value val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `lower_bound` that return an iterator, returns the first iterator in the range `rng` such that:
|
||||
without predicate - `*i < value` is `false`,
|
||||
with predicate - `pred(*i, value)` is `false`.
|
||||
|
||||
`end(rng)` is returned if no such iterator exists.
|
||||
|
||||
The versions of `lower_bound` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/lower_bound.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `Value` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng` is sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng` is sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
For ranges that model the __random_access_range__ concept the complexity is `O(log N)`, where `N` is `distance(rng)`.
|
||||
|
||||
For all other range types the complexity is `O(N)`.
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
|
51
doc/reference/algorithm/make_heap.qbk
Normal file
51
doc/reference/algorithm/make_heap.qbk
Normal file
@ -0,0 +1,51 @@
|
||||
[section:make_heap make_heap]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
void make_heap(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void make_heap(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
void make_heap(RandomAccessRange& rng, Compare pred);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
void make_heap(const RandomAccessRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`make_heap` turns `rng` into a heap.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/heap_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `3 * distance(rng)` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
81
doc/reference/algorithm/max_element.qbk
Normal file
81
doc/reference/algorithm/max_element.qbk
Normal file
@ -0,0 +1,81 @@
|
||||
[section:max_element max_element]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
max_element(ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
max_element(const ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
max_element(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
max_element(const ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
max_element(ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value_re,
|
||||
class ForwardRange
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
max_element(const ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
max_element(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
max_element(const ForwardRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `max_element` that return an iterator, return the iterator to the maximum value as determined by using `operator<` if a predicate is not supplied. Otherwise the predicate `pred` is used to determine the maximum value. The versions of `max_element` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/max_element.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Zero comparisons if `empty(rng)`, otherwise `distance(rng) - 1` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
83
doc/reference/algorithm/merge.qbk
Normal file
83
doc/reference/algorithm/merge.qbk
Normal file
@ -0,0 +1,83 @@
|
||||
[section:merge Range Algorithm - merge]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator merge(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator merge(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`merge` combines two sorted ranges `rng1` and `rng2` into a single sorted range by copying elements. `merge` is stable. The return value is `out + distance(rng1) + distance(rng2)`.
|
||||
|
||||
The two versions of `merge` differ by how they compare the elements.
|
||||
|
||||
The non-predicate version uses the `operator<()` for the range value type. The predicate version uses the predicate instead of `operator<()`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/merge.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `range_value<SinglePassRange1>::type` is the same as `range_value<SinglePassRange2>::type`.
|
||||
* `range_value<SinglePassRange1>::type` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering on objects of `range_value<SinglePassRange1>::type` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `range_value<SinglePassRange1>::type` is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `range_value<SinglePassRange1>::type` is the same as `range_value<SinglePassRange2>::type`.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to both `BinaryPredicate`'s argument types.
|
||||
* `range_value<SinglePassRange1>::type` is convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[heading For the non-predicate version:]
|
||||
|
||||
* The elements of `rng1` are in ascending order. That is, for each adjacent element pair `[x,y]` of `rng1`, `y < x == false`.
|
||||
* The elements of `rng2` are in ascending order. That is, for each adjacent element pair `[x,y]` of `rng2`, `y < x == false`.
|
||||
* The ranges `rng1` and `[out, out + distance(rng1) + distance(rng2))` do not overlap.
|
||||
* The ranges `rng2` and `[out, out + distance(rng1) + distance(rng2))` do not overlap.
|
||||
* `[out, out + distance(rng1) + distance(rng2))` is a valid range.
|
||||
|
||||
[heading For the predicate version:]
|
||||
|
||||
* The elements of `rng1` is in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng1`, `pred(y, x) == false`.
|
||||
* The elements of `rng2` is in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng2`, `pred(y, x) == false`.
|
||||
* The ranges `rng1` and `[out, out + distance(rng1) + distance(rng2))` do not overlap.
|
||||
* The ranges `rng2` and `[out, out + distance(rng1) + distance(rng2))` do not overlap.
|
||||
* `[out, out + distance(rng1) + distance(rng2))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. There are no comparisons if both `rng1` and `rng2` are empty, otherwise at most `distance(rng1) + distance(rng2) - 1` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
81
doc/reference/algorithm/min_element.qbk
Normal file
81
doc/reference/algorithm/min_element.qbk
Normal file
@ -0,0 +1,81 @@
|
||||
[section:min_element min_element]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
min_element(ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
min_element(const ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
min_element(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
min_element(const ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
min_element(ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value_re,
|
||||
class ForwardRange
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
min_element(const ForwardRange& rng);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
min_element(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
min_element(const ForwardRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `min_element` that return an iterator, return the iterator to the minimum value as determined by using `operator<` if a predicate is not supplied. Otherwise the predicate `pred` is used to determine the minimum value. The versions of `min_element` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/min_element.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Zero comparisons if `empty(rng)`, otherwise `distance(rng) - 1` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
116
doc/reference/algorithm/mismatch.qbk
Normal file
116
doc/reference/algorithm/mismatch.qbk
Normal file
@ -0,0 +1,116 @@
|
||||
[section:mismatch mismatch]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
std::pair<
|
||||
typename range_iterator<SinglePassRange1>::type,
|
||||
typename range_iterator<const SinglePassRange2>::type >
|
||||
mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2);
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
std::pair<
|
||||
typename range_iterator<const SinglePassRange1>::type,
|
||||
typename range_iterator<const SinglePassRange2>::type >
|
||||
mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2);
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
std::pair<
|
||||
typename range_iterator<SinglePassRange1>::type,
|
||||
typename range_iterator<SinglePassRange2>::type >
|
||||
mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2);
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
std::pair<
|
||||
typename range_iterator<const SinglePassRange1>::type,
|
||||
typename range_iterator<SinglePassRange2>::type >
|
||||
mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2);
|
||||
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
std::pair<
|
||||
typename range_iterator<SinglePassRange1>::type,
|
||||
typename range_iterator<const SinglePassRange2>::type >
|
||||
mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
std::pair<
|
||||
typename range_iterator<const SinglePassRange1>::type,
|
||||
typename range_iterator<const SinglePassRange2>::type >
|
||||
mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
std::pair<
|
||||
typename range_iterator<SinglePassRange1>::type,
|
||||
typename range_iterator<SinglePassRange2>::type >
|
||||
mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
std::pair<
|
||||
typename range_iterator<const SinglePassRange1>::type,
|
||||
typename range_iterator<SinglePassRange2>::type >
|
||||
mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `mismatch` that return an iterator, return an iterator to the first position where `rng1` and `rng2` differ.
|
||||
|
||||
Equality is determined by `operator==` for non-predicate versions of `mismatch`, and by satisfying `pred` in the predicate versions.
|
||||
|
||||
The versions of `mismatch` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/mismatch.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `SinglePassRange1`s value type can be compared for equality with `SinglePassRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
`distance(rng2) >= distance(rng1)`
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng1)` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
51
doc/reference/algorithm/next_permutation.qbk
Normal file
51
doc/reference/algorithm/next_permutation.qbk
Normal file
@ -0,0 +1,51 @@
|
||||
[section:next_permutation next_permutation]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange>
|
||||
void next_permutation(BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange>
|
||||
void next_permutation(const BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange, class Compare>
|
||||
void next_permutation(BidirectionalRange& rng, Compare pred);
|
||||
|
||||
template<class BidirectionalRange, class Compare>
|
||||
void next_permutation(const BidirectionalRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`next_permutation` transforms the range of elements `rng` into the lexicographically next greater permutation of the elements if such a permutation exists. If one does not exist then the range is transformed into the lexicographically smallest permutation and `false` is returned. `true` is returned when the next greater permutation is successfully generated.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/permutation.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `BidirectionalRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `BidirectionalRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `BidirectionalRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng) / 2` swaps.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
58
doc/reference/algorithm/nth_element.qbk
Normal file
58
doc/reference/algorithm/nth_element.qbk
Normal file
@ -0,0 +1,58 @@
|
||||
[section:nth_element Range Algorithm - nth_element]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
void nth_element(RandomAccessRange& rng,
|
||||
typename range_iterator<RandomAccessRange>::type nth);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void nth_element(const RandomAccessRange& rng,
|
||||
typename range_iterator<const RandomAccessRange>::type nth);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void nth_element(RandomAccessRange& rng,
|
||||
typename range_iterator<RandomAccessRange>::type nth,
|
||||
BinaryPredicate sort_pred);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void nth_element(const RandomAccessRange& rng,
|
||||
typename range_iterator<const RandomAccessRange>::type nth,
|
||||
BinaryPredicate sort_pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`nth_element` partially orders a range of elements. `nth_element` arranges the range `rng` such that the element corresponding with the iterator `nth` is the same as the element that would be in that position if `rng` has been sorted.
|
||||
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/nth_element.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering relation on `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
On average, linear in `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
60
doc/reference/algorithm/partial_sort.qbk
Normal file
60
doc/reference/algorithm/partial_sort.qbk
Normal file
@ -0,0 +1,60 @@
|
||||
[section:partial_sort Range Algorithm - partial_sort]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
void partial_sort(RandomAccessRange& rng,
|
||||
typename range_iterator<RandomAccessRange>::type middle);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void partial_sort(const RandomAccessRange& rng,
|
||||
typename range_iterator<const RandomAccessRange>::type middle);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void partial_sort(RandomAccessRange& rng,
|
||||
typename range_iterator<RandomAccessRange>::type middle,
|
||||
BinaryPredicate sort_pred);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void partial_sort(const RandomAccessRange& rng,
|
||||
typename range_iterator<const RandomAccessRange>::type middle,
|
||||
BinaryPredicate sort_pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`partial_sort` rearranges the elements in `rng`. It places the smallest `distance(begin(rng), middle)` elements, sorted in ascending order, into the range `[begin(rng), middle)`. The remaining elements are placed in an unspecified order into `[middle, last)`.
|
||||
|
||||
The non-predicative versions of this function specify that one element is less than another by using `operator<()`. The predicate versions use the predicate instead.
|
||||
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/partial_sort.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate version:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering relation on `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
|
||||
[*For the predicate version:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Approximately `distance(rng) * log(distance(begin(rng), middle))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
58
doc/reference/algorithm/partition.qbk
Normal file
58
doc/reference/algorithm/partition.qbk
Normal file
@ -0,0 +1,58 @@
|
||||
[section:partition Range Algorithm - partition]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
partition(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
partition(const ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
partition(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
partition(const ForwardRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`partition` orders the elements in `rng` based on `pred`, such that the elements that satisfy `pred` precede the elements that do not. In the versions that return a single iterator, the return value is the middle iterator. In the versions that have a configurable range_return, `found` corresponds to the middle iterator.
|
||||
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/partition.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `distance(rng)` applications of `pred`, and at most `distance(rng) / 2` swaps.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
56
doc/reference/algorithm/pop_heap.qbk
Normal file
56
doc/reference/algorithm/pop_heap.qbk
Normal file
@ -0,0 +1,56 @@
|
||||
[section:pop_heap pop_heap]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
void pop_heap(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void pop_heap(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
void pop_heap(RandomAccessRange& rng, Compare pred);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
void pop_heap(const RandomAccessRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`pop_heap` removes the largest element from the heap. It is assumed that `begin(rng), prior(end(rng))` is already a heap and that the element to be added is `*prior(end(rng))`.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/heap_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `!empty(rng)`
|
||||
* `rng` is a heap.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Logarithmic. At most `2 * log(distance(rng))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
51
doc/reference/algorithm/prev_permutation.qbk
Normal file
51
doc/reference/algorithm/prev_permutation.qbk
Normal file
@ -0,0 +1,51 @@
|
||||
[section:prev_permutation prev_permutation]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange>
|
||||
void prev_permutation(BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange>
|
||||
void prev_permutation(const BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange, class Compare>
|
||||
void prev_permutation(BidirectionalRange& rng, Compare pred);
|
||||
|
||||
template<class BidirectionalRange, class Compare>
|
||||
void prev_permutation(const BidirectionalRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`prev_permutation` transforms the range of elements `rng` into the lexicographically next smaller permutation of the elements if such a permutation exists. If one does not exist then the range is transformed into the lexicographically largest permutation and `false` is returned. `true` is returned when the next smaller permutation is successfully generated.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/permutation.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `BidirectionalRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `BidirectionalRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `BidirectionalRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng) / 2` swaps.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
56
doc/reference/algorithm/push_heap.qbk
Normal file
56
doc/reference/algorithm/push_heap.qbk
Normal file
@ -0,0 +1,56 @@
|
||||
[section:push_heap push_heap]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
void push_heap(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void push_heap(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
void push_heap(RandomAccessRange& rng, Compare pred);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
void push_heap(const RandomAccessRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`push_heap` adds an element to a heap. It is assumed that `begin(rng)`, `prior(end(rng))` is already a heap and that the element to be added is `*prior(end(rng))`.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/heap_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `!empty(rng)`
|
||||
* `[begin(rng), prior(end(rng)))` is a heap.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Logarithmic. At most `log(distance(rng))` comparisons.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
50
doc/reference/algorithm/random_shuffle.qbk
Normal file
50
doc/reference/algorithm/random_shuffle.qbk
Normal file
@ -0,0 +1,50 @@
|
||||
[section:random_shuffle Range Algorithm - random_shuffle]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& random_shuffle(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& random_shuffle(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Generator>
|
||||
RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen);
|
||||
|
||||
template<class RandomAccessRange, class Generator>
|
||||
const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`random_shuffle` randomly rearranges the elements in `rng`. The versions of `random_shuffle` that do not specify a `Generator` use an internal random number generator. The versions of `random_shuffle` that do specify a `Generator` use this instead. Returns the shuffles range.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/random_shuffle.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the version without a Generator:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
|
||||
[*For the version with a Generator:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `Generator` is a model of the `RandomNumberGeneratorConcept`.
|
||||
* `RandomAccessRange`'s distance type is convertible to `Generator`'s argument type.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `distance(rng)` is less than `gen`'s maximum value.
|
||||
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. If `!empty(rng)`, exactly `distance(rng) - 1` swaps are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
58
doc/reference/algorithm/remove.qbk
Normal file
58
doc/reference/algorithm/remove.qbk
Normal file
@ -0,0 +1,58 @@
|
||||
[section:remove Range Algorithm - remove]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
remove(ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
remove(const ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<ForwardRange,re>::type
|
||||
remove(ForwardRange& rng, const Value& val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<const ForwardRange,re>::type
|
||||
remove(const ForwardRange& rng, const Value& val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`remove` removes from `rng` all of the elements `x` for which `x == val` is `true`. The versions of `remove` that return an iterator, return an iterator `new_last` such that the range `[begin(rng), new_last)` contains no elements equal to `val`. The `range_return` versions of `remove` defines `found` as the new last element. The iterators in the range `[new_last, end(rng))` are dereferenceable, but the elements are unspecified.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/remove.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is a model of the `EqualityComparableConcept`.
|
||||
* Objects of type `Value` can be compared for equality with objects of `ForwardRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `remove` performs exactly `distance(rng)` comparisons for equality.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
58
doc/reference/algorithm/remove_if.qbk
Normal file
58
doc/reference/algorithm/remove_if.qbk
Normal file
@ -0,0 +1,58 @@
|
||||
[section:remove_if Range Algorithm - remove_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
remove(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
remove(const ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange,re>::type
|
||||
remove(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange,re>::type
|
||||
remove(const ForwardRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`remove_if` removes from `rng` all of the elements `x` for which `pred(x)` is `true`. The versions of `remove_if` that return an iterator, return an iterator `new_last` such that the range `[begin(rng), new_last)` contains no elements where `pred(x)` is `true`. The iterators in the range `[new_last, end(rng))` are dereferenceable, but the elements are unspecified.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/remove_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `remove_if` performs exactly `distance(rng)` applications of `pred`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
41
doc/reference/algorithm/replace.qbk
Normal file
41
doc/reference/algorithm/replace.qbk
Normal file
@ -0,0 +1,41 @@
|
||||
[section:replace Range Algorithm - replace]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
ForwardRange& replace(ForwardRange& rng, const Value& what, const Value& with_what);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
const ForwardRange& replace(const ForwardRange& rng, const Value& what, const Value& with_what);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`replace` every element in `rng` equal to `what` with `with_what`. Return a reference to `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/replace.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
* `Value` is a model of the `EqualityComparableConcept`, and may be compared for equality with objects of `ForwardRange`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `replace` performs exactly `distance(rng)` comparisons for equality and at most `distance(rng)` assignments.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
36
doc/reference/algorithm/replace_if.qbk
Normal file
36
doc/reference/algorithm/replace_if.qbk
Normal file
@ -0,0 +1,36 @@
|
||||
[section:replace_if Range Algorithm - replace_if]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class UnaryPredicate, class Value>
|
||||
ForwardRange& replace_if(ForwardRange& rng, UnaryPredicate pred, const Value& with_what);
|
||||
|
||||
template<class ForwardRange, class UnaryPredicate, class Value>
|
||||
const ForwardRange& replace_if(const ForwardRange& rng, UnaryPredicate pred, const Value& with_what);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`replace_if` replaces every element `x` in `rng` for which `pred(x) == true` with `with_what`. Returns a reference to `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/replace_if.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`
|
||||
* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type.
|
||||
* `Value` is convertible to `ForwardRange`'s value type.
|
||||
* `Value` is a model of the `AssignableConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `replace_if` performs exactly `distance(rng)` applications of `pred`, and at most `distance(rng)` assignments.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
32
doc/reference/algorithm/reverse.qbk
Normal file
32
doc/reference/algorithm/reverse.qbk
Normal file
@ -0,0 +1,32 @@
|
||||
[section:reverse Range Algorithm - reverse]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class BidirectionalRange>
|
||||
BidirectionalRange& reverse(BidirectionalRange& rng);
|
||||
|
||||
template<class BidirectionalRange>
|
||||
const BidirectionalRange& reverse(const BidirectionalRange& rng);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`reverse` reverses a range. Returns a reference to the reversed range.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/reverse.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
|
||||
* `BidirectionalRange` is mutable.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `reverse` makes `distance(rng)/2` calls to `iter_swap`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
39
doc/reference/algorithm/rotate.qbk
Normal file
39
doc/reference/algorithm/rotate.qbk
Normal file
@ -0,0 +1,39 @@
|
||||
[section:rotate Range Algorithm - rotate]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
ForwardRange& rotate(ForwardRange& rng,
|
||||
typename range_iterator<ForwardRange>::type middle);
|
||||
|
||||
template<class ForwardRange>
|
||||
const ForwardRange& rotate(const ForwardRange& rng,
|
||||
typename range_iterator<const ForwardRange>::type middle);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`rotate` rotates the elements in a range. It exchanges the two ranges `[begin(rng), middle)` and `[middle, end(rng))`. Returns a reference to `rng`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/rotate.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
* `[begin(rng), middle)` is a valid range.
|
||||
* `[middle, end(rng))` is a valid range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. At most `distance(rng)` swaps are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
101
doc/reference/algorithm/search.qbk
Normal file
101
doc/reference/algorithm/search.qbk
Normal file
@ -0,0 +1,101 @@
|
||||
[section:search search]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange1, class ForwardRange2>
|
||||
typename range_iterator<ForwardRange1>::type
|
||||
search(ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<class ForwardRange1, class ForwardRange2>
|
||||
typename range_iterator<const ForwardRange1>::type
|
||||
search(const ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange1>::type,
|
||||
search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_iterator<const ForwardRange1>::type
|
||||
search(const ForwardRange1& rng1, ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<ForwardRange1, re>::type
|
||||
search(ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2
|
||||
>
|
||||
typename range_return<const ForwardRange1, re>::type
|
||||
search(const ForwardRange1& rng1, const ForwardRange2& rng2);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange1, re>::type,
|
||||
search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange1,
|
||||
class ForwardRange2,
|
||||
class BinaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange1, re>::type
|
||||
search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `search` that return an iterator, return an iterator to the start of the first subsequence in `rng1` that is equal to the subsequence `rng2`. The `end(rng1)` is returned if no such subsequence exists in `rng1`.
|
||||
Equality is determined by `operator==` for non-predicate versions of `search`, and by satisfying `pred` in the predicate versions.
|
||||
|
||||
The versions of `search` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/search.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange1` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange1`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `ForwardRange2`'s value type is a model of the `EqualityComparableConcept`.
|
||||
* `ForwardRange1`s value type can be compared for equality with `ForwardRange2`'s value type.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange1` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange2` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Average complexity is Linear. Worst-case complexity is quadratic.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
76
doc/reference/algorithm/set_difference.qbk
Normal file
76
doc/reference/algorithm/set_difference.qbk
Normal file
@ -0,0 +1,76 @@
|
||||
[section:set_difference set_difference]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator set_difference(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator set_difference(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`set_difference` constructs a sorted range that is the set difference of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
76
doc/reference/algorithm/set_intersection.qbk
Normal file
76
doc/reference/algorithm/set_intersection.qbk
Normal file
@ -0,0 +1,76 @@
|
||||
[section:set_intersection set_intersection]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator set_intersection(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator set_intersection(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`set_intersection` constructs a sorted range that is the intersection of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
78
doc/reference/algorithm/set_symmetric_difference.qbk
Normal file
78
doc/reference/algorithm/set_symmetric_difference.qbk
Normal file
@ -0,0 +1,78 @@
|
||||
[section:set_symmetric_difference set_symmetric_difference]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator
|
||||
set_symmetric_difference(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator
|
||||
set_symmetric_difference(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`set_symmetric_difference` constructs a sorted range that is the set symmetric difference of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
75
doc/reference/algorithm/set_union.qbk
Normal file
75
doc/reference/algorithm/set_union.qbk
Normal file
@ -0,0 +1,75 @@
|
||||
[section:set_union set_union]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator
|
||||
>
|
||||
OutputIterator set_union(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryPredicate
|
||||
>
|
||||
OutputIterator set_union(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`set_union` constructs a sorted range that is the union of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range.
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/set_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `SinglePassRange1` and `SinglePassRange2` have the same value type.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
|
||||
* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng1` and `rng2` are sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
53
doc/reference/algorithm/sort.qbk
Normal file
53
doc/reference/algorithm/sort.qbk
Normal file
@ -0,0 +1,53 @@
|
||||
[section:sort Range Algorithm - sort]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& sort(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& sort(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class BinaryPredicate>
|
||||
RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class RandomAccessRange, class BinaryPredicate>
|
||||
const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`sort` sorts the elements in `rng` into ascending order. `sort` is not guaranteed to be stable. Returns the sorted range.
|
||||
|
||||
For versions of the `sort` function without a predicate, ascending order is defined by `operator<()` such that for all adjacent elements `[x,y]`, `y < x == false`.
|
||||
|
||||
For versions of the `sort` function with a predicate, ascending order is defined by `pred` such that for all adjacent elements `[x,y]`, `pred(y, x) == false`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/sort.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For versions of sort without a predicate:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering relation on `RandomAccessRange`'s value type is a [*strict weak ordering], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For versions of sort with a predicate]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
`O(N log(N))` comparisons (both average and worst-case), where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
55
doc/reference/algorithm/sort_heap.qbk
Normal file
55
doc/reference/algorithm/sort_heap.qbk
Normal file
@ -0,0 +1,55 @@
|
||||
[section:sort_heap sort_heap]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
void sort_heap(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
void sort_heap(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
void sort_heap(RandomAccessRange& rng, Compare pred);
|
||||
|
||||
template<class RandomAccessRange, class Compare>
|
||||
void sort_heap(const RandomAccessRange& rng, Compare pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`sort_heap` turns a heap into a sorted range.
|
||||
|
||||
The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/heap_algorithm.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `Compare` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
`rng` is a heap.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
At most `N * log(N)` comparisons, where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
56
doc/reference/algorithm/stable_partition.qbk
Normal file
56
doc/reference/algorithm/stable_partition.qbk
Normal file
@ -0,0 +1,56 @@
|
||||
[section:stable_partition Range Algorithm - stable_partition]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class UnaryPredicate>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
stable_partition(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<class ForwardRange, class UnaryPredicate>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
stable_partition(const ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
stable_partition(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
stable_partition(const ForwardRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`stable_partition` reorders the elements in the range `rng` base on the function object `pred`. Once this function has completed all of the elements that satisfy `pred` appear before all of the elements that fail to satisfy it. `stable_partition` differs from `partition` because it preserves relative order. It is table.
|
||||
|
||||
For the versions that return an iterator, the return value is the iterator to the first element that fails to satisfy `pred`.
|
||||
|
||||
For versions that return a `range_return`, the `found` iterator is the iterator to the first element that fails to satisfy `pred`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/stable_partition.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `UnaryPredicate` is a model of the `PredicateConcept`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Best case: `O(N)` where `N` is `distance(rng)`.
|
||||
Worst case: `N * log(N)` swaps, where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
54
doc/reference/algorithm/stable_sort.qbk
Normal file
54
doc/reference/algorithm/stable_sort.qbk
Normal file
@ -0,0 +1,54 @@
|
||||
[section:stable_sort Range Algorithm - stable_sort]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class RandomAccessRange>
|
||||
RandomAccessRange& stable_sort(RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange>
|
||||
const RandomAccessRange& stable_sort(const RandomAccessRange& rng);
|
||||
|
||||
template<class RandomAccessRange, class BinaryPredicate>
|
||||
RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class RandomAccessRange, class BinaryPredicate>
|
||||
const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`stable_sort` sorts the elements in `rng` into ascending order. `stable_sort` is guaranteed to be stable. The order is preserved for equivalent elements.
|
||||
|
||||
For versions of the `stable_sort` function without a predicate ascending order is defined by `operator<()` such that for all adjacent elements `[x,y]`, `y < x == false`.
|
||||
|
||||
For versions of the `stable_sort` function with a predicate, ascending order is designed by `pred` such that for all adjacent elements `[x,y]`, `pred(y,x) == false`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/stable_sort.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For versions of stable_sort without a predicate]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
|
||||
* The ordering relation on `RandomAccessRange`'s value type is a [*strict weak ordering], as defined in the `LessThanComparableConcept` requirements.
|
||||
|
||||
[*For versions of stable_sort with a predicate:]
|
||||
|
||||
* `RandomAccessRange` is a model of the __random_access_range__ Concept.
|
||||
* `RandomAccessRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Best case: `O(N)` where `N` is `distance(rng)`.
|
||||
Worst case: `O(N log(N)^2)` comparisons, where `N` is `distance(rng)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
83
doc/reference/algorithm/transform.qbk
Normal file
83
doc/reference/algorithm/transform.qbk
Normal file
@ -0,0 +1,83 @@
|
||||
[section:transform Range Algorithm - transform]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class OutputIterator,
|
||||
class UnaryOperation
|
||||
>
|
||||
OutputIterator transform(const SinglePassRange1& rng,
|
||||
OutputIterator out,
|
||||
UnaryOperation fun);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class OutputIterator,
|
||||
class BinaryOperation
|
||||
>
|
||||
OutputIterator transform(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
OutputIterator out,
|
||||
BinaryOperation fun);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
[*UnaryOperation version:]
|
||||
|
||||
`transform` assigns the value `y` to each element `[out, out + distance(rng)), y = fun(x)` where `x` is the corresponding value to `y` in `rng1`. The return value is `out + distance(rng)`.
|
||||
|
||||
[*BinaryOperation version:]
|
||||
|
||||
`transform` assigns the value `z` to each element `[out, out + min(distance(rng1), distance(rng2))), z = fun(x,y)` where `x` is the corresponding value in `rng1` and `y` is the corresponding value in `rng2`. This version of `transform` stops upon reaching either the end of `rng1`, or the end of `rng2`. Hence there isn't a requirement for `distance(rng1) == distance(rng2)` since there is a safe guaranteed behaviour, unlike with the iterator counterpart in the standard library.
|
||||
|
||||
The return value is `out + min(distance(rng1), distance(rng2))`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/transform.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the unary versions of transform:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `UnaryOperation` is a model of the `UnaryFunctionConcept`.
|
||||
* `SinglePassRange1`'s value type must be convertible to `UnaryFunction`'s argument type.
|
||||
* `UnaryFunction`'s result type must be convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[*For the binary versions of transform:]
|
||||
|
||||
* `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
* `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
* `OutputIterator` is a model of the `OutputIteratorConcept`.
|
||||
* `BinaryOperation` is a model of the `BinaryFunctionConcept`.
|
||||
* `SinglePassRange1`'s value type must be convertible to `BinaryFunction`'s first argument type.
|
||||
* `SinglePassRange2`'s value type must be convertible to `BinaryFunction`'s second argument type.
|
||||
* `BinaryOperation`'s result type must be convertible to a type in `OutputIterator`'s set of value types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the unary version of transform:]
|
||||
|
||||
* `out` is not an iterator within the range `[begin(rng1) + 1, end(rng1))`.
|
||||
* `[out, out + distance(rng1))` is a valid range.
|
||||
|
||||
[*For the binary version of transform:]
|
||||
|
||||
* `out` is not an iterator within the range `[begin(rng1) + 1, end(rng1))`.
|
||||
* `out` is not an iterator within the range `[begin(rng2) + 1, end(rng2))`.
|
||||
* `[out, out + min(distance(rng1), distance(rng2)))` is a valid range.
|
||||
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. The operation is applied exactly `distance(rng1)` for the unary version and `min(distance(rng1), distance(rng2))` for the binary version.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
72
doc/reference/algorithm/unique.qbk
Normal file
72
doc/reference/algorithm/unique.qbk
Normal file
@ -0,0 +1,72 @@
|
||||
[section:unique Range Algorithm - unique]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange>
|
||||
typename range_return<ForwardRange, return_begin_found>::type
|
||||
unique(ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange>
|
||||
typename range_return<const ForwardRange, return_begin_found>::type
|
||||
unique(const ForwardRange& rng);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_return<ForwardRange, return_begin_found>::type
|
||||
unique(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<class ForwardRange, class BinaryPredicate>
|
||||
typename range_return<const ForwardRange, return_begin_found>::type
|
||||
unique(const ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<range_return_value re, class ForwardRange>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
unique(ForwardRange& rng);
|
||||
|
||||
template<range_return_value re, class ForwardRange>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
unique(const ForwardRange& rng);
|
||||
|
||||
template<range_return_value re, class ForwardRange, class BinaryPredicate>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
unique(ForwardRange& rng, BinaryPredicate pred);
|
||||
|
||||
template<range_return_value re, class ForwardRange, class BinaryPredicate>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
unique(const ForwardRange& rng, BinaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`unique` removes all but the first element of each sequence of duplicate encountered in `rng`.
|
||||
|
||||
Elements in the range `[new_last, end(rng))` are dereferenceable but undefined.
|
||||
|
||||
Equality is determined by the predicate if one is supplied, or by `operator==()` for `ForwardRange`'s value type.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/unique.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions of unique:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `ForwardRange`'s value type is a model of the `EqualityComparableConcept`.
|
||||
|
||||
[*For the predicate versions of unique:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `ForwardRange` is mutable.
|
||||
* `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
|
||||
* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type and to `BinaryPredicate`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `O(N)` where `N` is `distance(rng)`. Exactly `distance(rng)` comparisons are performed.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
77
doc/reference/algorithm/upper_bound.qbk
Normal file
77
doc/reference/algorithm/upper_bound.qbk
Normal file
@ -0,0 +1,77 @@
|
||||
[section:upper_bound upper_bound]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<class ForwardRange, class Value>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
upper_bound(ForwardRange& rng, Value val);
|
||||
|
||||
template<class ForwardRange, class Value>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
upper_bound(const ForwardRange& rng, Value val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<ForwardRange, re>::type
|
||||
upper_bound(ForwardRange& rng, Value val);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
class ForwardRange,
|
||||
class Value
|
||||
>
|
||||
typename range_return<const ForwardRange, re>::type
|
||||
upper_bound(const ForwardRange& rng, Value val);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
The versions of `upper_bound` that return an iterator, returns the first iterator in the range `rng` such that:
|
||||
without predicate - `val < *i` is `true`,
|
||||
with predicate - `pred(val, *i)` is `true`.
|
||||
|
||||
`end(rng)` is returned if no such iterator exists.
|
||||
|
||||
The versions of `upper_bound` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm/upper_bound.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `Value` is a model of the `LessThanComparableConcept`.
|
||||
* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
* `ForwardRange` is a model of the __forward_range__ Concept.
|
||||
* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
|
||||
* `ForwardRange`'s value type is the same type as `Value`.
|
||||
* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
|
||||
|
||||
[heading Precondition:]
|
||||
|
||||
[*For the non-predicate versions:]
|
||||
|
||||
`rng` is sorted in ascending order according to `operator<`.
|
||||
|
||||
[*For the predicate versions:]
|
||||
|
||||
`rng` is sorted in ascending order according to `pred`.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
For ranges that model the __random_access_range__ Concept the complexity is `O(log N)`, where `N` is `distance(rng)`. For all other range types the complexity is `O(N)`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
30
doc/reference/algorithm_ext/erase.qbk
Normal file
30
doc/reference/algorithm_ext/erase.qbk
Normal file
@ -0,0 +1,30 @@
|
||||
[section:erase erase]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class Container,
|
||||
class SinglePassRange
|
||||
>
|
||||
void erase(Container& target,
|
||||
iterator_range<typename Container::iterator> to_erase);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`erase` the iterator range `to_erase` from the container `target`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm_ext/erase.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
# `Container` supports erase of an iterator range.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Proprotional to `distance(to_erase)`.
|
||||
|
||||
[endsect]
|
68
doc/reference/algorithm_ext/for_each.qbk
Normal file
68
doc/reference/algorithm_ext/for_each.qbk
Normal file
@ -0,0 +1,68 @@
|
||||
[section:for_each for_each]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryFunction
|
||||
>
|
||||
BinaryFunction for_each(const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
BinaryFunction fn);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryFunction
|
||||
>
|
||||
BinaryFunction for_each(const SinglePassRange1& rng1,
|
||||
SinglePassRange2& rng2,
|
||||
BinaryFunction fn);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryFunction
|
||||
>
|
||||
BinaryFunction for_each(SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
BinaryFunction fn);
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class BinaryFunction
|
||||
>
|
||||
BinaryFunction for_each(SinglePassRange1& rng1,
|
||||
SinglePassRange2& rng2,
|
||||
BinaryFunction fn);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`for_each` traverses forward through `rng1` and `rng2` simultaneously.
|
||||
For each iteration, the element `x` is used from `rng1` and the corresponding
|
||||
element `y` is used from `rng2` to invoke `fn(x,y)`.
|
||||
|
||||
Iteration is stopped upon reaching the end of the shorter of `rng1`, or `rng2`.
|
||||
It is safe to call this function with unequal length ranges.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm_ext/for_each.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
# `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
# `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
# `BinaryFunction` is a model of the `BinaryFunctionConcept`.
|
||||
# `SinglePassRange1`'s value type is convertible to `BinaryFunction`'s first argument type.
|
||||
# `SinglepassRange2`'s value type is convertible to `BinaryFunction`'s second argument type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. Exactly `min(distance(rng1), distance(rng2))` applications of `BinaryFunction`.
|
||||
|
||||
[endsect]
|
33
doc/reference/algorithm_ext/insert.qbk
Normal file
33
doc/reference/algorithm_ext/insert.qbk
Normal file
@ -0,0 +1,33 @@
|
||||
[section:insert insert]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class Container,
|
||||
class SinglePassRange
|
||||
>
|
||||
void insert(Container& target,
|
||||
typename Container::iterator before,
|
||||
const SinglePassRange& from);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`insert` all of the elements in the range `from` before the `before` iterator into `target`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm_ext/insert.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
# `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
# `Container` supports insert at a specified position.
|
||||
# `SinglePassRange`'s value type is convertible to `Container`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `distance(from)` assignments are performed.
|
||||
|
||||
[endsect]
|
34
doc/reference/algorithm_ext/overwrite.qbk
Normal file
34
doc/reference/algorithm_ext/overwrite.qbk
Normal file
@ -0,0 +1,34 @@
|
||||
[section:overwrite overwrite]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2
|
||||
>
|
||||
void overwrite(const SinglePassRange1& from,
|
||||
SinglePassRange2& to);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`overwrite` assigns the values from the range `from` into the range `to`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm_ext/overwrite.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
# `SinglePassRange1` is a model of the __single_pass_range__ Concept.
|
||||
# `SinglePassRange2` is a model of the __single_pass_range__ Concept.
|
||||
# `SinglePassRange2` is mutable.
|
||||
# `distance(SinglePassRange1) <= distance(SinglePassRange2)`
|
||||
# `SinglePassRange1`'s value type is convertible to `SinglePassRange2`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `distance(rng1)` assignments are performed.
|
||||
|
||||
[endsect]
|
32
doc/reference/algorithm_ext/push_back.qbk
Normal file
32
doc/reference/algorithm_ext/push_back.qbk
Normal file
@ -0,0 +1,32 @@
|
||||
[section:push_back push_back]
|
||||
|
||||
[heading Prototype]
|
||||
|
||||
``
|
||||
template<
|
||||
class Container,
|
||||
class SinglePassRange
|
||||
>
|
||||
void push_back(Container& target,
|
||||
const SinglePassRange& from);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
||||
`push_back` all of the elements in the range `from` to the back of the container `target`.
|
||||
|
||||
[heading Definition]
|
||||
|
||||
Defined in the header file `boost/range/algorithm_ext/push_back.hpp`
|
||||
|
||||
[heading Requirements]
|
||||
|
||||
# `SinglePassRange` is a model of the __single_pass_range__ Concept.
|
||||
# `Container` supports insert at `end()`.
|
||||
# `SinglePassRange`'s value type is convertible to `Container`'s value type.
|
||||
|
||||
[heading Complexity]
|
||||
|
||||
Linear. `distance(from)` assignments are performed.
|
||||
|
||||
[endsect]
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user