00001
00002
00008 #if !defined(__ads_algorithm_sort_h__)
00009 #define __ads_algorithm_sort_h__
00010
00011 #include "Triplet.h"
00012
00013 #include "../functor/compose.h"
00014 #include "../functor/select.h"
00015
00016 #include <algorithm>
00017 #include <vector>
00018
00019 #include <cassert>
00020
00021 BEGIN_NAMESPACE_ADS
00022
00023
00025
00026
00027
00029
00033 template<typename RandomAccessIterator1, typename RandomAccessIterator2,
00034 typename Compare>
00035 void
00036 sortTogether(RandomAccessIterator1 begin1, RandomAccessIterator1 end1,
00037 RandomAccessIterator2 begin2, RandomAccessIterator2 end2,
00038 Compare compare1);
00039
00040
00042 template<typename RandomAccessIterator1, typename RandomAccessIterator2>
00043 inline
00044 void
00045 sortTogether(RandomAccessIterator1 begin1, RandomAccessIterator1 end1,
00046 RandomAccessIterator2 begin2, RandomAccessIterator2 end2) {
00047 sortTogether(begin1, end1, begin2, end2,
00048 std::less<typename std::iterator_traits<RandomAccessIterator1>::
00049 value_type>());
00050 }
00051
00052
00054
00058 template<typename RandomAccessIterator1, typename RandomAccessIterator2,
00059 typename RandomAccessIterator3, typename Compare>
00060 void
00061 sortTogether(RandomAccessIterator1 begin1, RandomAccessIterator1 end1,
00062 RandomAccessIterator2 begin2, RandomAccessIterator2 end2,
00063 RandomAccessIterator3 begin3, RandomAccessIterator3 end3,
00064 Compare compare1);
00065
00066
00068 template<typename RandomAccessIterator1, typename RandomAccessIterator2,
00069 typename RandomAccessIterator3>
00070 inline
00071 void
00072 sortTogether(RandomAccessIterator1 begin1, RandomAccessIterator1 end1,
00073 RandomAccessIterator2 begin2, RandomAccessIterator2 end2,
00074 RandomAccessIterator3 begin3, RandomAccessIterator3 end3) {
00075 sortTogether(begin1, end1, begin2, end2, begin3, end3,
00076 std::less<typename std::iterator_traits<RandomAccessIterator1>::
00077 value_type>());
00078 }
00079
00080
00082 template<typename InputIterator, typename IntOutputIterator>
00083 void
00084 computeOrder(InputIterator begin, InputIterator end, IntOutputIterator order);
00085
00086
00088 template<typename RandomAccessIterator, typename IntInputIterator>
00089 void
00090 orderByRank(RandomAccessIterator begin, RandomAccessIterator end,
00091 IntInputIterator ranks);
00092
00093
00094
00095
00096 END_NAMESPACE_ADS
00097
00098 #define __ads_algorithm_sort_ipp__
00099 #include "sort.ipp"
00100 #undef __ads_algorithm_sort_ipp__
00101
00102 #endif