#include <sorthelper.h>
template<typename T>
class SortHelper< T >
Definition at line 36 of file sorthelper.h.
◆ SortHelper()
Definition at line 59 of file sorthelper.h.
60 counts_.reserve(sizehint);
◆ Add()
Definition at line 65 of file sorthelper.h.
67 for (
int i = 0; i < counts_.size(); ++i) {
68 if (counts_[i].value == value) {
69 counts_[i].count +=
count;
73 SortPair<T> new_pair = {value,
count};
74 counts_.push_back(SortPair<T>(new_pair));
◆ MaxCount()
template<typename T >
int SortHelper< T >::MaxCount |
( |
T * |
max_value | ) |
const |
|
inline |
Definition at line 80 of file sorthelper.h.
81 int best_count = -INT32_MAX;
82 for (
int i = 0; i < counts_.size(); ++i) {
83 if (counts_[i].
count > best_count) {
84 best_count = counts_[i].count;
85 if (max_value !=
nullptr)
86 *max_value = counts_[i].value;
◆ SortByCount()
Definition at line 93 of file sorthelper.h.
static int SortPairsByCount(const void *v1, const void *v2)
◆ SortByValue()
Definition at line 98 of file sorthelper.h.
static int SortPairsByValue(const void *v1, const void *v2)
◆ SortPairsByCount()
template<typename T >
static int SortHelper< T >::SortPairsByCount |
( |
const void * |
v1, |
|
|
const void * |
v2 |
|
) |
| |
|
inlinestatic |
Definition at line 44 of file sorthelper.h.
45 const SortPair<T>* p1 =
static_cast<const SortPair<T>*
>(v1);
46 const SortPair<T>* p2 =
static_cast<const SortPair<T>*
>(v2);
47 return p2->count - p1->count;
◆ SortPairsByValue()
template<typename T >
static int SortHelper< T >::SortPairsByValue |
( |
const void * |
v1, |
|
|
const void * |
v2 |
|
) |
| |
|
inlinestatic |
Definition at line 50 of file sorthelper.h.
51 const SortPair<T>* p1 =
static_cast<const SortPair<T>*
>(v1);
52 const SortPair<T>* p2 =
static_cast<const SortPair<T>*
>(v2);
53 if (p2->value - p1->value < 0)
return -1;
54 if (p2->value - p1->value > 0)
return 1;
The documentation for this class was generated from the following file: