diff -r 31d224a3c0af -r de16f1f2d228 lemon/radix_sort.h --- a/lemon/radix_sort.h Tue Dec 02 10:17:30 2008 +0000 +++ b/lemon/radix_sort.h Tue Dec 02 23:15:43 2008 +0100 @@ -217,7 +217,7 @@ /// which maps the items to any integer type which can be either /// signed or unsigned. /// - /// \sa counterSort() + /// \sa stableRadixSort() template void radixSort(Iterator first, Iterator last, Functor functor) { using namespace _radix_sort_bits; @@ -264,8 +264,8 @@ } template - void counterIntroSort(Key *first, Key *last, Key *target, - int byte, Functor functor) { + void stableRadixIntroSort(Key *first, Key *last, Key *target, + int byte, Functor functor) { const int size = unsigned(std::numeric_limits::max()) + 1; std::vector counter(size); @@ -290,8 +290,8 @@ } template - void signedCounterIntroSort(Key *first, Key *last, Key *target, - int byte, Functor functor) { + void signedStableRadixIntroSort(Key *first, Key *last, Key *target, + int byte, Functor functor) { const int size = unsigned(std::numeric_limits::max()) + 1; std::vector counter(size); @@ -322,7 +322,7 @@ template - void counterSignedSort(Iterator first, Iterator last, Functor functor) { + void stableRadixSignedSort(Iterator first, Iterator last, Functor functor) { if (first == last) return; typedef typename std::iterator_traits::value_type Key; typedef std::allocator Allocator; @@ -335,21 +335,21 @@ std::copy(first, last, buffer); for (int i = 0; i < int(sizeof(Value)) - 1; ++i) { if (dir) { - counterIntroSort(buffer, buffer + length, buffer + length, - i, functor); + stableRadixIntroSort(buffer, buffer + length, buffer + length, + i, functor); } else { - counterIntroSort(buffer + length, buffer + 2 * length, buffer, - i, functor); + stableRadixIntroSort(buffer + length, buffer + 2 * length, buffer, + i, functor); } dir = !dir; } if (dir) { - signedCounterIntroSort(buffer, buffer + length, buffer + length, - sizeof(Value) - 1, functor); + signedStableRadixIntroSort(buffer, buffer + length, buffer + length, + sizeof(Value) - 1, functor); std::copy(buffer + length, buffer + 2 * length, first); } else { - signedCounterIntroSort(buffer + length, buffer + 2 * length, buffer, - sizeof(Value) - 1, functor); + signedStableRadixIntroSort(buffer + length, buffer + 2 * length, + buffer, sizeof(Value) - 1, functor); std::copy(buffer, buffer + length, first); } } catch (...) { @@ -360,7 +360,8 @@ } template - void counterUnsignedSort(Iterator first, Iterator last, Functor functor) { + void stableRadixUnsignedSort(Iterator first, Iterator last, + Functor functor) { if (first == last) return; typedef typename std::iterator_traits::value_type Key; typedef std::allocator Allocator; @@ -373,11 +374,11 @@ std::copy(first, last, buffer); for (int i = 0; i < int(sizeof(Value)); ++i) { if (dir) { - counterIntroSort(buffer, buffer + length, - buffer + length, i, functor); + stableRadixIntroSort(buffer, buffer + length, + buffer + length, i, functor); } else { - counterIntroSort(buffer + length, buffer + 2 * length, - buffer, i, functor); + stableRadixIntroSort(buffer + length, buffer + 2 * length, + buffer, i, functor); } dir = !dir; } @@ -397,18 +398,18 @@ template ::is_signed > - struct CounterSortSelector { + struct StableRadixSortSelector { template static void sort(Iterator first, Iterator last, Functor functor) { - counterSignedSort(first, last, functor); + stableRadixSignedSort(first, last, functor); } }; template - struct CounterSortSelector { + struct StableRadixSortSelector { template static void sort(Iterator first, Iterator last, Functor functor) { - counterUnsignedSort(first, last, functor); + stableRadixUnsignedSort(first, last, functor); } }; @@ -423,7 +424,7 @@ /// order according to an integer mapping in the same as radixSort() does. /// /// This sorting algorithm is stable, i.e. the order of two equal - /// element remains the same after the sorting. + /// elements remains the same after the sorting. /// /// This sort algorithm use a radix forward sort on the /// bytes of the integer number. The algorithm sorts the items @@ -444,41 +445,41 @@ /// signed or unsigned. /// \sa radixSort() template - void counterSort(Iterator first, Iterator last, Functor functor) { + void stableRadixSort(Iterator first, Iterator last, Functor functor) { using namespace _radix_sort_bits; typedef typename Functor::result_type Value; - CounterSortSelector::sort(first, last, functor); + StableRadixSortSelector::sort(first, last, functor); } template - void counterSort(Iterator first, Iterator last, Value (*functor)(Key)) { + void stableRadixSort(Iterator first, Iterator last, Value (*functor)(Key)) { using namespace _radix_sort_bits; - CounterSortSelector::sort(first, last, functor); + StableRadixSortSelector::sort(first, last, functor); } template - void counterSort(Iterator first, Iterator last, Value& (*functor)(Key)) { + void stableRadixSort(Iterator first, Iterator last, Value& (*functor)(Key)) { using namespace _radix_sort_bits; - CounterSortSelector::sort(first, last, functor); + StableRadixSortSelector::sort(first, last, functor); } template - void counterSort(Iterator first, Iterator last, Value (*functor)(Key&)) { + void stableRadixSort(Iterator first, Iterator last, Value (*functor)(Key&)) { using namespace _radix_sort_bits; - CounterSortSelector::sort(first, last, functor); + StableRadixSortSelector::sort(first, last, functor); } template - void counterSort(Iterator first, Iterator last, Value& (*functor)(Key&)) { + void stableRadixSort(Iterator first, Iterator last, Value& (*functor)(Key&)) { using namespace _radix_sort_bits; - CounterSortSelector::sort(first, last, functor); + StableRadixSortSelector::sort(first, last, functor); } template - void counterSort(Iterator first, Iterator last) { + void stableRadixSort(Iterator first, Iterator last) { using namespace _radix_sort_bits; typedef typename std::iterator_traits::value_type Value; - CounterSortSelector::sort(first, last, Identity()); + StableRadixSortSelector::sort(first, last, Identity()); } }