diff --git a/doc/sort.qbk b/doc/sort.qbk index 73087c0..639656c 100644 --- a/doc/sort.qbk +++ b/doc/sort.qbk @@ -131,9 +131,10 @@ In all cases, this operator must return an integer type that compares with the `operator<` to provide the intended order (integers can be negated to reverse their order). -In other words: +In other words (aside from negative floats, which are inverted as ints): rightshift(A, n) < rightshift(B, n) -> A < B + A < B -> rightshift(A, 0) < rightshift(B, 0) [rightshift_1] [bracket_1] @@ -141,9 +142,10 @@ In other words: See [@../../example/rightshiftsample.cpp rightshiftsample.cpp] for a working example of integer sorting with a rightshift functor. And a version with a comparison functor for maximum flexibility. -This functor must provide the same sorting order as the integers returned by the rightshift: +This functor must provide the same sorting order as the integers returned by the rightshift (aside from negative floats): rightshift(A, n) < rightshift(B, n) -> compare(A, B) + compare(A, B) -> rightshift(A, 0) < rightshift(B, 0) [reverse_int_2] diff --git a/include/boost/sort/spreadsort/detail/string_sort.hpp b/include/boost/sort/spreadsort/detail/string_sort.hpp index ef943b8..582508f 100644 --- a/include/boost/sort/spreadsort/detail/string_sort.hpp +++ b/include/boost/sort/spreadsort/detail/string_sort.hpp @@ -285,7 +285,7 @@ namespace spreadsort { ++last; //Offsetting on identical characters. This section works //a few characters at a time for optimal worst-case performance. - update_offset(first, last, + update_offset(curr, last, char_offset); RandomAccessIter * target_bin; diff --git a/test/string_sort_test.cpp b/test/string_sort_test.cpp index a75f5ee..84dc25b 100644 --- a/test/string_sort_test.cpp +++ b/test/string_sort_test.cpp @@ -101,8 +101,9 @@ void string_test() for (unsigned u = 0; u < input_count; ++u) { unsigned length = rand() % max_length; string result; - for (unsigned u = 0; u < length; ++u) + for (unsigned v = 0; v < length; ++v) { result.push_back(rand() % 256); + } base_vec.push_back(result); } vector sorted_vec = base_vec; @@ -112,6 +113,7 @@ void string_test() string_sort(test_vec.begin(), test_vec.end()); BOOST_CHECK(test_vec == sorted_vec); //Testing boost::sort::spreadsort wrapper + test_vec = base_vec; boost::sort::spreadsort::spreadsort(test_vec.begin(), test_vec.end()); BOOST_CHECK(test_vec == sorted_vec); //Character functors