ProteoWizard
copy_iftest.cpp
Go to the documentation of this file.
1 //
2 // $Id: copy_iftest.cpp 5471 2014-01-09 10:15:33Z witek96 $
3 //
4 //
5 // Original author: Witold Wolski <wewolski@gmail.com>
6 //
7 // Copyright : ETH Zurich
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 //
21 
22 
26 #include <boost/bind.hpp>
27 #include <vector>
28 
29 namespace {
30  using namespace pwiz::util;
31  void copyif()
32  {
33  double x[] = {1,3,5,1,3,5,1,3,5,1,3,5};
34  double y[] = {2,4,6,2,4,6,2,4,6,2,4,6};
35 
36  std::vector<double> res;
37 
38  ralab::base::utils::copy_if(x,x+sizeof(x)/sizeof(double),std::back_inserter(res),boost::bind(std::less<double>(), _1, 2 ) );
39  unit_assert_operator_equal(res.size(),4);
40  res.clear();
41  ralab::base::utils::copy_if_not(x,x+sizeof(x)/sizeof(double),std::back_inserter(res),boost::bind(std::less<double>(), _1, 2 ) );
42  unit_assert_operator_equal(res.size(),8);
43  res.clear();
44  }
45 
46  //tmp
47  void copyif2()
48  {
49  double x[] = {1,3,5,1,3,5,1,3,5,1,3,5};
50  double y[] = {2,4,6,2,4,6,2,4,6,2,4,6};
51 
52  std::vector<double> res;
53  ralab::base::utils::copy_if(x,x+sizeof(x)/sizeof(double),y,
54  std::back_inserter(res),
55  boost::bind(std::less<double>(), _1, 2 ) );
56  unit_assert_operator_equal(res.size(),4);
58  res.clear();
59  ralab::base::utils::copy_if_not(x,x+sizeof(x)/sizeof(double),y,
60  std::back_inserter(res),boost::bind(std::less<double>(), _1, 2 ) );
61  unit_assert_operator_equal(res.size(),8);
63  res.clear();
64  }
65 }//namespace
66 
67 int main(int argc, char **argv) {
68 copyif();
69 copyif2();
70  return 0;
71 }
72 
73 
int main(int argc, char **argv)
Definition: copy_iftest.cpp:67
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
OutputIterator copy_if(InputIterator first, InputIterator last, InputIterator2 source, OutputIterator result, Predicate pred)
Definition: copyif.hpp:35
OutputIterator copy_if_not(InputIterator first, InputIterator last, InputIterator2 source, OutputIterator result, Predicate pred)
Definition: copyif.hpp:56