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 <algorithm>
00028 #include <iterator>
00029 #include <vector>
00030
00031 namespace theplu {
00032 namespace yat {
00033 namespace utility {
00034
00047 template<typename ForwardIterator>
00048 void sort_index(ForwardIterator first, ForwardIterator last,
00049 std::vector<size_t>& sort_index);
00050
00051
00057 void sort_index(StrideIterator<double*> first,
00058 StrideIterator<double*> last,
00059 std::vector<size_t>& sort_index);
00060
00066 void sort_index(StrideIterator<const double*> first,
00067 StrideIterator<const double*> last,
00068 std::vector<size_t>& sort_index);
00069
00075 void sort_index(std::vector<double>::iterator first,
00076 std::vector<double>::iterator last,
00077 std::vector<size_t>& sort_index);
00078
00084 void sort_index(std::vector<double>::const_iterator first,
00085 std::vector<double>::const_iterator last,
00086 std::vector<size_t>& sort_index);
00087
00088
00089
00090
00091 template<typename ForwardIterator>
00092 void sort_index(ForwardIterator first, ForwardIterator last,
00093 std::vector<size_t>& result)
00094 {
00095 std::vector<double> vec;
00096 vec.reserve(std::distance(first, last));
00097 std::copy(first, last,
00098 std::back_insert_iterator<std::vector<double> >(vec));
00099 sort_index(vec.begin(), vec.end(), result);
00100 }
00101
00102 }}}
00103
00104 #endif