Changeset 1042:d450a02728d0 in lemon-main
- Timestamp:
- 03/19/10 18:23:47 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/radix_sort.h
r559 r1042 35 35 namespace _radix_sort_bits { 36 36 37 template <typename Iterator> 38 bool unitRange(Iterator first, Iterator last) { 39 ++first; 40 return first == last; 41 } 42 37 43 template <typename Value> 38 44 struct Identity { … … 61 67 std::iter_swap(first, last); 62 68 ++first; 63 if (!(first < last)) {64 return first;65 }66 69 while (true) { 67 70 while (!(functor(*first) & mask)) { … … 72 75 --last; 73 76 } 74 if ( !(first < last)) {77 if (unitRange(last, first)) { 75 78 return first; 76 79 } … … 98 101 std::iter_swap(first, last); 99 102 ++first; 100 if (!(first < last)) {101 return first;102 }103 103 while (true) { 104 104 while (functor(*first) < 0) { … … 109 109 --last; 110 110 } 111 if ( !(first < last)) {111 if (unitRange(last, first)) { 112 112 return first; 113 113 } … … 120 120 void radixIntroSort(Iterator first, Iterator last, 121 121 Functor functor, Value mask) { 122 while (mask != 0 && last - first > 1) {122 while (mask != 0 && first != last && !unitRange(first, last)) { 123 123 Iterator cut = radixSortPartition(first, last, functor, mask); 124 124 mask >>= 1;
Note: See TracChangeset
for help on using the changeset viewer.