yat  0.12.3pre
sort_index.h
1 #ifndef _theplu_yat_utility_sort_index_
2 #define _theplu_yat_utility_sort_index_
3 
4 // $Id: sort_index.h 2202 2010-02-21 18:39:13Z peter $
5 
6 /*
7  Copyright (C) 2008, 2010 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include "StrideIterator.h"
26 
27 #include <boost/concept_check.hpp>
28 
29 #include <algorithm>
30 #include <iterator>
31 #include <vector>
32 
33 namespace theplu {
34 namespace yat {
35 namespace utility {
36 
49  template<typename ForwardIterator>
50  void sort_index(ForwardIterator first, ForwardIterator last,
51  std::vector<size_t>& sort_index);
52 
53 
59  void sort_index(StrideIterator<double*> first,
60  StrideIterator<double*> last,
61  std::vector<size_t>& sort_index);
62 
68  void sort_index(StrideIterator<const double*> first,
69  StrideIterator<const double*> last,
70  std::vector<size_t>& sort_index);
71 
77  void sort_index(std::vector<double>::iterator first,
78  std::vector<double>::iterator last,
79  std::vector<size_t>& sort_index);
80 
86  void sort_index(std::vector<double>::const_iterator first,
87  std::vector<double>::const_iterator last,
88  std::vector<size_t>& sort_index);
89 
90 
91  // template implementation
92 
93  template<typename ForwardIterator>
94  void sort_index(ForwardIterator first, ForwardIterator last,
95  std::vector<size_t>& result)
96  {
97  BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
98  std::vector<double> vec;
99  vec.reserve(std::distance(first, last));
100  std::copy(first, last,
101  std::back_insert_iterator<std::vector<double> >(vec));
102  sort_index(vec.begin(), vec.end(), result);
103  }
104 
105 }}} // of namespace utility, yat, and theplu
106 
107 #endif
void sort_index(ForwardIterator first, ForwardIterator last, std::vector< size_t > &sort_index)
Definition: sort_index.h:94

Generated on Mon Jun 1 2015 12:29:52 for yat by  doxygen 1.8.5