Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
filter.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_ALGORITHM_FILTER_HPP
9#define ADOBE_ALGORITHM_FILTER_HPP
10
11#include <adobe/config.hpp>
12
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15
16#include <algorithm>
17#include <functional>
18
19/**************************************************************************************************/
20
21namespace adobe {
22
23/**************************************************************************************************/
48/**************************************************************************************************/
49#ifndef ADOBE_NO_DOCUMENTATION
50namespace implementation {
51
52/**************************************************************************************************/
53
54template <typename I, // I models InputIterator
55 typename O, // O models OutputIterator
56 typename F>
57// F is a function type of the form O F()(value_type(I), O)
58O filter(I first, I last, O result, F op) {
59 while (first != last) {
60 result = op(*first, result);
61 ++first;
62 }
63 return result;
64}
65
66/**************************************************************************************************/
67
68} // namespace implementation
69#endif
70/**************************************************************************************************/
76template <typename I, // I models InputIterator
77 typename O, // O models OutputIterator
78 typename F>
79// F is a function type of the form O F()(value_type(I), O)
80inline O filter(I first, I last, O result, F op) {
81 return implementation::filter(first, last, result,
82 std::bind<O>(op, std::placeholders::_1, std::placeholders::_2));
83}
84
90template <typename I, // I models InputRange
91 typename O, // O models OutputIterator
92 typename F>
93// F is a function type of the form O F()(value_type(I), O)
94O filter(I& source, O result, F op) {
95 return adobe::filter(boost::begin(source), boost::end(source), result, op);
96}
97
103template <typename I, // I models InputRange
104 typename O, // O models OutputIterator
105 typename F>
106// F is a function type of the form O F()(value_type(I), O)
107O filter(const I& source, O result, F op) {
108 return adobe::filter(boost::begin(source), boost::end(source), result, op);
109}
110
111/**************************************************************************************************/
112
113} // namespace adobe
114
115/**************************************************************************************************/
116
117#endif
118
119/**************************************************************************************************/
O filter(I first, I last, O result, F op)
filter implementation
Definition filter.hpp:80