From 3326d79337c82a840d6a50537e696cc336af3d9b Mon Sep 17 00:00:00 2001 From: Steven Ross Date: Sun, 11 Oct 2015 20:53:32 -0400 Subject: [PATCH 1/3] Documentation update to clarify float_sort. --- doc/sort.qbk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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] From c02e2924c3c403f4e527f92276d8ee962dbbf64c Mon Sep 17 00:00:00 2001 From: Steven Ross Date: Thu, 14 Apr 2016 23:09:27 -0400 Subject: [PATCH 2/3] Using curr in reverse_string_sort_rec to fix update_offset call. This bug can cause a performance hit, but should not impact accuracy. --- include/boost/sort/spreadsort/detail/string_sort.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 11e8bf247a69c1c0027e33ae49f7da6595d8f8c9 Mon Sep 17 00:00:00 2001 From: Steven Ross Date: Thu, 14 Apr 2016 23:15:12 -0400 Subject: [PATCH 3/3] Minor clean up for string_sort_test --- test/string_sort_test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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