diff --git a/doc/html/range/library_headers/adaptors.html b/doc/html/range/library_headers/adaptors.html new file mode 100644 index 0000000..f8810a4 --- /dev/null +++ b/doc/html/range/library_headers/adaptors.html @@ -0,0 +1,232 @@ + +
+ +![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Header + + |
+
+ + Includes + + |
+
---|---|
+
+ |
++ + | +
+
+ |
+
+ + copied + + |
+
+
+ |
+
+ + filtered + + |
+
+
+ |
+
+ + indexed + + |
+
+
+ |
+
+ + indirected + + |
+
+
+ |
+
+ + map_keys + map_values + + |
+
+
+ |
+
+ + replaced + + |
+
+
+ |
+
+ + replaced_if + + |
+
+
+ |
+
+ + reversed + + |
+
+
+ |
+
+ + sliced + + |
+
+
+ |
+
+ + strided + + |
+
+
+ |
+
+ + tokenized + + |
+
+
+ |
+
+ + transformed + + |
+
+
+ |
+
+ + uniqued + + |
+
+ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Header + + |
+
+ + Includes + + |
+
---|---|
+
+ |
+
+ + adjacent_find + + |
+
+
+ |
+
+ + binary_search + + |
+
+
+ |
+
+ + copy + + |
+
+
+ |
+
+ + copy_backward + + |
+
+
+ |
+
+ + count + + |
+
+
+ |
+
+ + count_if + + |
+
+
+ |
+
+ + equal + + |
+
+
+ |
+
+ + equal_range + + |
+
+
+ |
+
+ + fill + + |
+
+
+ |
+
+ + fill_n + + |
+
+
+ |
+
+ + find + + |
+
+
+ |
+
+ + find_end + + |
+
+
+ |
+
+ + find_first_of + + |
+
+
+ |
+
+ + find_if + + |
+
+
+ |
+
+ + for_each + + |
+
+
+ |
+
+ + generate + + |
+
+
+ |
++ + | +
+
+ |
+
+ + inplace_merge + + |
+
+
+ |
++ + | +
+
+ |
+
+ + lower_bound + + |
+
+
+ |
+
+ + max_element + + |
+
+
+ |
+
+ + merge + + |
+
+
+ |
+
+ + min_element + + |
+
+
+ |
+
+ + mismatch + + |
+
+
+ |
+
+ + nth_element + + |
+
+
+ |
+
+ + partial_sort + + |
+
+
+ |
+
+ + partition + + |
+
+
+ |
++ + | +
+
+ |
+
+ + random_shuffle + + |
+
+
+ |
+
+ + remove + + |
+
+
+ |
+
+ + remove_copy + + |
+
+
+ |
+
+ + remove_copy_if + + |
+
+
+ |
+
+ + remove_if + + |
+
+
+ |
+
+ + replace + + |
+
+
+ |
+
+ + replace_copy + + |
+
+
+ |
+
+ + replace_copy_if + + |
+
+
+ |
+
+ + replace_if + + |
+
+
+ |
+
+ + reverse + + |
+
+
+ |
+
+ + reverse_copy + + |
+
+
+ |
+
+ + rotate + + |
+
+
+ |
+
+ + rotate_copy + + |
+
+
+ |
+
+ + search + + |
+
+
+ |
+
+ + search_n + + |
+
+
+ |
+
+ + includes + set_union + set_intersection + set_difference + set_symmetric_difference + + |
+
+
+ |
+
+ + sort + + |
+
+
+ |
+
+ + stable_partition + + |
+
+
+ |
+
+ + swap_ranges + + |
+
+
+ |
+
+ + transform + + |
+
+
+ |
+
+ + unique + + |
+
+
+ |
+
+ + unique_copy + + |
+
+
+ |
+
+ + upper_bound + + |
+
+ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Header + + |
+
+ + Includes + + |
+
---|---|
+
+ |
+
+ + copy_n + + |
+
+
+ |
+
+ + erase + + |
+
+
+ |
+
+ + for_each + + |
+
+
+ |
+
+ + insert + + |
+
+
+ |
+
+ + iota + + |
+
+
+ |
+
+ + is_sorted + + |
+
+
+ |
+
+ + overwrite + + |
+
+
+ |
+
+ + push_back + + |
+
+
+ |
+
+ + push_front + + |
+
+ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Header + + |
+
+ + Includes + + |
+
+ + Related Concept + + |
+
---|---|---|
+
+ |
+
+ + everything from Boost.Range version 1 (Boost versions 1.42 and + below). Includes the core range functions and metafunctinos, but + excludes Range Adaptors and Range Algorithms. + + |
+
+ + - + + |
+
+
+ |
+
+ + every metafunction + + |
+
+ + - + + |
+
+
+ |
+
+ + every function + + |
+
+ + - + + |
+
+
+ |
+
+
+ |
++ + | +
+
+ |
+
+
+ |
++ + | +
+
+ |
+
+
+ |
+
+ + Forward Range + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
++ + | ++ + | +
+
+ |
+
+
+ |
++ + | +
+
+ |
++ + | ++ + | +
+
+ |
+
+
+ |
++ + | +
+
+ |
+
+
+ |
+
+ + Forward Range + + |
+
+
+ |
+
+
+ |
++ + | +
+
+ |
+
+
+ |
++ + | +
+
+ |
+
+
+ |
++ + | +
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
+
+ + Range concepts + + |
+
+ + - + + |
+
+
+ |
+
+ + every range adaptor + + |
+
+ + - + + |
+
+
+ |
+
+ + every range equivalent of an STL algorithm + + |
+
+ + - + + |
+
+
+ |
+
+ + every range algorithm that is an extension of the STL algorithms + + |
+
+ + - + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+
+ |
+
+
+ |
+
+ + - + + |
+
+ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
value_type
+ of the range is convertible to both argument types of bi_pred
.
+ [x,y]
in the returned range, bi_pred(x,y)
+ is true
.
+ bi_pred
might throw.
+ SinglePassRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+1,2,3,4,5,6 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
0
+ <= n
+ && n
+ <= m
+ && m
+ < distance(rng)
+iterator_range
+ that holds the sliced range [n,m)
+ of the original range.
+ RandomAccessRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+2,3,4,5 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
value_type
+ of the range is convertible to the argument type of pred
.
+ [x]
in the returned range, pred(x)
+ is true
.
+ pred
might throw.
+ ForwardRange
+ForwardRange
++ +
+#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, ",")); +} ++
+
++ This would produce the output: +
+2,4,6,8 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
index()
+ member function that returns the appropriate index for the element
+ in the sequence corresponding with the iterator.
+ SinglePassRange
++ +
+#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; +} ++
+
++ 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 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
value_type
+ of the range defines unary operator*()
+x
in the returned range, x
is the result of *y
+ where y
is the corresponding
+ element in the original range.
+ SinglePassRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+0,1,2,3,4,5,6,7,8,9 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
value_type
+ of the range is an instantiation of std::pair
.
+ x
in the returned range, x
is the result of y.first
where y
+ is the corresponding element in the original range.
+ SinglePassRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+0,1,2,3,4,5,6,7,8,9 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
value_type
+ of the range is an instantiation of std::pair
.
+ x
in the returned range, x
is the result of y.second
where y
+ is the corresponding element in the original range.
+ SinglePassRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+0,10,20,30,40,50,60,70,80,90 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
new_value
is convertible
+ to the value_type
+ of the range.
+ old_value
is convertible
+ to the value_type
+ of the range.
+ 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.
+ ForwardRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+1,10,3,10,5,10,7,10,9 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
value_type
+ is convertible to the argument type of pred
.
+ new_value
is convertible
+ to the value_type
+ of the range.
+ 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.
+ ForwardRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+1,10,3,10,5,10,7,10,9 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
reverse_iterator
.
+ BidirectionalRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+9,8,7,6,5,4,3,2,1 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
0
+ <= n
+ && n
+ <= m
+ && m
+ < distance(rng)
+make_range(rng, n, m)
+RandomAccessRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+3,4,5 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
0
+ <= n
+ && n
+ < distance(rng)
+rng
where traversal is performed
+ in steps of n
.
+ RandomAccessRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+1,3,5,7,9 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + 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) ++ + + |
+
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
.
+ value_type
+ of rndRng
is int
.
+ flags
has the type
+ regex_constants::syntax_option_type
.
+ 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.
+ regex_token_iterator
s
+ might throw.
+ RandomAccessRange
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
value_type
+ of the range is convertible to the argument type of fun
.
+ x
in the returned range, x
is the result of fun(y)
+ where y
is the corresponding
+ element in the original range.
+ fun
might throw.
+ SinglePassRange
++ +
+#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; +} ++
+
++ This would produce the output: +
+2,4,6,8,10,12,14,16,18,20 ++
+
++ | + |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ + Syntax + + |
+
+ + Code + + |
+
---|---|
+ + Pipe + + |
+
+
+ |
+
+ + Function + + |
+
+
+ |
+
value_type
+ of the range is comparable with operator==()
.
+ [x,y]
in the returned range, x==y
is false.
+ ForwardRange
++ +
+#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, ",")); +} ++
+
++ This would produce the output: +
+1,2,3,4,5,6 ++
+
++ | + |