StringRadixSort#
-
class numpy::StringRadixSort#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use StringRadixSort
StringRadixSort obj;
// ... operations ...
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
void |
NP_STRING_SORT.H:294 |
|
|
void |
NP_STRING_SORT.H:233 |
|
|
void |
NP_STRING_SORT.H:222 |
|
|
void |
NP_STRING_SORT.H:247 |
Code Examples#
The following examples are extracted from the test suite.
lsd_radix_sort (np_test_1_all.cpp:12635)
12625 std::cout << "========= test_string_radix_sort_lsd =======================";
12626
12627 // Fixed-length strings for LSD radix sort
12628 std::vector<std::string> strings = {
12629 "dog", "cat", "bat", "rat", "mat", "hat", "pat", "sat"
12630 };
12631
12632 std::vector<std::string> expected = strings;
12633 std::sort(expected.begin(), expected.end());
12634
12635 StringRadixSort::lsd_radix_sort(strings, 3);
12636
12637 if (!(strings == expected)) {
12638 std::string description = std::string("test_string_radix_sort_lsd():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(strings == expected)";
12639 std::cout << std::string("[FAIL] ") + description << std::endl;
12640 throw std::runtime_error(description);
12641 }
12642 if (!(std::is_sorted(strings.begin(), strings.end()))) {
12643 std::string description = std::string("test_string_radix_sort_lsd():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(strings.begin(), strings.end()))";
12644 std::cout << std::string("[FAIL] ") + description << std::endl;
12645 throw std::runtime_error(description);
msd_radix_sort (np_test_1_all.cpp:12606)
12596 void test_string_radix_sort_msd() {
12597 std::cout << "========= test_string_radix_sort_msd =======================";
12598
12599 std::vector<std::string> strings = {
12600 "cat", "car", "card", "care", "careful", "cars", "carry", "cart"
12601 };
12602
12603 std::vector<std::string> expected = strings;
12604 std::sort(expected.begin(), expected.end());
12605
12606 StringRadixSort::msd_radix_sort(strings);
12607
12608 if (!(strings == expected)) {
12609 std::string description = std::string("test_string_radix_sort_msd():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(strings == expected)";
12610 std::cout << std::string("[FAIL] ") + description << std::endl;
12611 throw std::runtime_error(description);
12612 }
12613 if (!(std::is_sorted(strings.begin(), strings.end()))) {
12614 std::string description = std::string("test_string_radix_sort_msd():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(strings.begin(), strings.end()))";
12615 std::cout << std::string("[FAIL] ") + description << std::endl;
12616 throw std::runtime_error(description);