stlab.adobe.com Adobe Systems Incorporated
filter.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 
7 /*************************************************************************************************/
8 
9 #ifndef ADOBE_ALGORITHM_FILTER_HPP
10 #define ADOBE_ALGORITHM_FILTER_HPP
11 
12 #include <adobe/config.hpp>
13 
14 #include <boost/range/begin.hpp>
15 #include <boost/range/end.hpp>
16 #include <boost/bind.hpp>
17 
18 #include <algorithm>
19 
20 /*************************************************************************************************/
21 
22 namespace adobe {
23 
24 /*************************************************************************************************/
50 /*************************************************************************************************/
51 #ifndef ADOBE_NO_DOCUMENTATION
52 namespace implementation {
53 
54 /*************************************************************************************************/
55 
56 template <typename I, // I models InputIterator
57  typename O, // O models OutputIterator
58  typename F> // F is a function type of the form O F()(value_type(I), O)
59 O filter(I first, I last, O result, F op)
60 {
61  while (first != last)
62  {
63  result = op(*first, result);
64  ++first;
65  }
66  return result;
67 }
68 
69 /*************************************************************************************************/
70 
71 } // namespace implementation
72 #endif
73 /*************************************************************************************************/
79 template <typename I, // I models InputIterator
80  typename O, // O models OutputIterator
81  typename F> // F is a function type of the form O F()(value_type(I), O)
82 inline O filter(I first, I last, O result, F op)
83 {
84  return implementation::filter(first, last, result, boost::bind<O>(op, _1, _2));
85 }
86 
92 template <typename I, // I models InputRange
93  typename O, // O models OutputIterator
94  typename F> // F is a function type of the form O F()(value_type(I), O)
95 O filter(I& source, O result, F op)
96 {
97  return adobe::filter(boost::begin(source), boost::end(source), result, op);
98 }
99 
105 template <typename I, // I models InputRange
106  typename O, // O models OutputIterator
107  typename F> // F is a function type of the form O F()(value_type(I), O)
108 O filter(const I& source, O result, F op)
109 {
110  return adobe::filter(boost::begin(source), boost::end(source), result, op);
111 }
112 
113 /*************************************************************************************************/
114 
115 } // namespace adobe
116 
117 /*************************************************************************************************/
118 
119 #endif
120 
121 /*************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google