RecordSorter#
-
class numpy::RecordSorter#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use RecordSorter
RecordSorter obj;
// ... operations ...
Sorting#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
void |
NP_SORTING_ALGORITHMS.H:1444 |
Math Operations#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
void |
NP_SORTING_ALGORITHMS.H:1440 |
Code Examples#
The following examples are extracted from the test suite.
sort (np_test_1_all.cpp:6258)
6248 std::vector<int> data = gen.generate(100, DataPattern::FEW_UNIQUE);
6249
6250 if (!(data.size() == 100)) {
6251 std::string description = std::string("test_data_generator_few_uniqueBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 100)";
6252 std::cout << std::string("[FAIL] ") + description << std::endl;
6253 throw std::runtime_error(description);
6254 }
6255
6256 // Count unique values
6257 std::vector<int> sorted_copy = data;
6258 std::sort(sorted_copy.begin(), sorted_copy.end());
6259 auto unique_end = std::unique(sorted_copy.begin(), sorted_copy.end());
6260 size_t unique_count = std::distance(sorted_copy.begin(), unique_end);
6261
6262 // Should have significantly fewer unique values than total elements
6263 if (!(unique_count < data.size() / 2)) {
6264 std::string description = std::string("test_data_generator_few_uniqueBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(unique_count < data.size() / 2)";
6265 std::cout << std::string("[FAIL] ") + description << std::endl;
6266 throw std::runtime_error(description);
6267 }