20 #ifndef TESSERACT_CCUTIL_SORTHELPER_H_
21 #define TESSERACT_CCUTIL_SORTHELPER_H_
45 const auto* p1 =
static_cast<const SortPair<T>*
>(v1);
46 const auto* p2 =
static_cast<const SortPair<T>*
>(v2);
47 return p2->
count - p1->count;
51 const auto* p1 =
static_cast<const SortPair<T>*
>(v1);
52 const auto* 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;
60 counts_.reserve(sizehint);
67 for (
int i = 0; i < counts_.size(); ++i) {
68 if (counts_[i].value == value) {
69 counts_[i].count +=
count;
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;
108 #endif // TESSERACT_CCUTIL_SORTHELPER_H_.