StringRadixSort =============== .. cpp:class:: numpy::StringRadixSort numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use StringRadixSort StringRadixSort obj; // ... operations ... Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void counting_sort_by_position(StringType \*strings, StringType \*temp, size_tcount, size_tpos)`` - void - NP_STRING_SORT.H:294 - * - ``void lsd_radix_sort(StringContainer &strings, size_tmax_length)`` - void - NP_STRING_SORT.H:233 - :ref:`View ` * - ``void msd_radix_sort(StringContainer &strings)`` - void - NP_STRING_SORT.H:222 - :ref:`View ` * - ``void msd_sort_impl(StringType \*strings, StringType \*temp, size_tcount, size_tdepth)`` - void - NP_STRING_SORT.H:247 - Code Examples ------------- The following examples are extracted from the test suite. .. _example-stringradixsort-lsd_radix_sort-0: .. dropdown:: lsd_radix_sort (np_test_1_all.cpp:12635) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 12625 :emphasize-lines: 11 std::cout << "========= test_string_radix_sort_lsd ======================="; // Fixed-length strings for LSD radix sort std::vector strings = { "dog", "cat", "bat", "rat", "mat", "hat", "pat", "sat" }; std::vector expected = strings; std::sort(expected.begin(), expected.end()); StringRadixSort::lsd_radix_sort(strings, 3); if (!(strings == expected)) { std::string description = std::string("test_string_radix_sort_lsd():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(strings == expected)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } if (!(std::is_sorted(strings.begin(), strings.end()))) { std::string description = std::string("test_string_radix_sort_lsd():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(strings.begin(), strings.end()))"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); .. _example-stringradixsort-msd_radix_sort-1: .. dropdown:: msd_radix_sort (np_test_1_all.cpp:12606) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 12596 :emphasize-lines: 11 void test_string_radix_sort_msd() { std::cout << "========= test_string_radix_sort_msd ======================="; std::vector strings = { "cat", "car", "card", "care", "careful", "cars", "carry", "cart" }; std::vector expected = strings; std::sort(expected.begin(), expected.end()); StringRadixSort::msd_radix_sort(strings); if (!(strings == expected)) { std::string description = std::string("test_string_radix_sort_msd():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(strings == expected)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } if (!(std::is_sorted(strings.begin(), strings.end()))) { std::string description = std::string("test_string_radix_sort_msd():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(strings.begin(), strings.end()))"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description);