00001 #ifndef _theplu_yat_utility_sort_index_
00002 #define _theplu_yat_utility_sort_index_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "StrideIterator.h"
00026
00027 #include <boost/concept_check.hpp>
00028
00029 #include <algorithm>
00030 #include <iterator>
00031 #include <vector>
00032
00033 namespace theplu {
00034 namespace yat {
00035 namespace utility {
00036
00049 template<typename ForwardIterator>
00050 void sort_index(ForwardIterator first, ForwardIterator last,
00051 std::vector<size_t>& sort_index);
00052
00053
00059 void sort_index(StrideIterator<double*> first,
00060 StrideIterator<double*> last,
00061 std::vector<size_t>& sort_index);
00062
00068 void sort_index(StrideIterator<const double*> first,
00069 StrideIterator<const double*> last,
00070 std::vector<size_t>& sort_index);
00071
00077 void sort_index(std::vector<double>::iterator first,
00078 std::vector<double>::iterator last,
00079 std::vector<size_t>& sort_index);
00080
00086 void sort_index(std::vector<double>::const_iterator first,
00087 std::vector<double>::const_iterator last,
00088 std::vector<size_t>& sort_index);
00089
00090
00091
00092
00093 template<typename ForwardIterator>
00094 void sort_index(ForwardIterator first, ForwardIterator last,
00095 std::vector<size_t>& result)
00096 {
00097 BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
00098 std::vector<double> vec;
00099 vec.reserve(std::distance(first, last));
00100 std::copy(first, last,
00101 std::back_insert_iterator<std::vector<double> >(vec));
00102 sort_index(vec.begin(), vec.end(), result);
00103 }
00104
00105 }}}
00106
00107 #endif