RecordSorter ============ .. cpp:class:: numpy::RecordSorter numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use RecordSorter RecordSorter obj; // ... operations ... Sorting ------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void sort(std::vector&records, boolstable = true)`` - void - NP_SORTING_ALGORITHMS.H:1444 - :ref:`View ` Math Operations --------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void add_field(const std::string &name, FieldComparatorcomp, boolascending = true)`` - void - NP_SORTING_ALGORITHMS.H:1440 - Code Examples ------------- The following examples are extracted from the test suite. .. _example-recordsorter-sort-0: .. dropdown:: sort (np_test_1_all.cpp:6258) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 6248 :emphasize-lines: 11 std::vector data = gen.generate(100, DataPattern::FEW_UNIQUE); if (!(data.size() == 100)) { std::string description = std::string("test_data_generator_few_uniqueBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 100)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } // Count unique values std::vector sorted_copy = data; std::sort(sorted_copy.begin(), sorted_copy.end()); auto unique_end = std::unique(sorted_copy.begin(), sorted_copy.end()); size_t unique_count = std::distance(sorted_copy.begin(), unique_end); // Should have significantly fewer unique values than total elements if (!(unique_count < data.size() / 2)) { std::string description = std::string("test_data_generator_few_uniqueBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(unique_count < data.size() / 2)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); }