20 #ifndef TESSERACT_CCUTIL_SORTHELPER_H_ 21 #define TESSERACT_CCUTIL_SORTHELPER_H_ 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_. static int SortPairsByValue(const void *v1, const void *v2)
void Add(T value, int count)
static int SortPairsByCount(const void *v1, const void *v2)
int MaxCount(T *max_value) const
const GenericVector< SortPair< T > > & SortByCount()
const GenericVector< SortPair< T > > & SortByValue()