Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/sort.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,21 @@ 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]

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]

Expand Down
2 changes: 1 addition & 1 deletion include/boost/sort/spreadsort/detail/string_sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RandomAccessIter, Unsigned_char_type>(first, last,
update_offset<RandomAccessIter, Unsigned_char_type>(curr, last,
char_offset);
RandomAccessIter * target_bin;

Expand Down
4 changes: 3 additions & 1 deletion test/string_sort_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> sorted_vec = base_vec;
Expand All @@ -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
Expand Down