Tesseract
3.02
|
#include <sorthelper.h>
Classes | |
struct | SortPair |
Public Member Functions | |
SortHelper (int sizehint) | |
void | Add (T value, int count) |
int | MaxCount (T *max_value) const |
const GenericVector< SortPair < T > > & | SortByCount () |
const GenericVector< SortPair < T > > & | SortByValue () |
Static Public Member Functions | |
static int | SortPairsByCount (const void *v1, const void *v2) |
static int | SortPairsByValue (const void *v1, const void *v2) |
Definition at line 36 of file sorthelper.h.
SortHelper< T >::SortHelper | ( | int | sizehint | ) | [inline, explicit] |
Definition at line 59 of file sorthelper.h.
: counts_(sizehint) {}
void SortHelper< T >::Add | ( | T | value, |
int | count | ||
) | [inline] |
int SortHelper< T >::MaxCount | ( | T * | max_value | ) | const [inline] |
const GenericVector<SortPair<T> >& SortHelper< T >::SortByCount | ( | ) | [inline] |
Definition at line 91 of file sorthelper.h.
{ counts_.sort(&SortPairsByCount); return counts_; }
const GenericVector<SortPair<T> >& SortHelper< T >::SortByValue | ( | ) | [inline] |
Definition at line 96 of file sorthelper.h.
{ counts_.sort(&SortPairsByValue); return counts_; }
static int SortHelper< T >::SortPairsByCount | ( | const void * | v1, |
const void * | v2 | ||
) | [inline, static] |
Definition at line 44 of file sorthelper.h.
{ const SortPair<T>* p1 = reinterpret_cast<const SortPair<T>*>(v1); const SortPair<T>* p2 = reinterpret_cast<const SortPair<T>*>(v2); return p2->count - p1->count; }
static int SortHelper< T >::SortPairsByValue | ( | const void * | v1, |
const void * | v2 | ||
) | [inline, static] |
Definition at line 50 of file sorthelper.h.
{ const SortPair<T>* p1 = reinterpret_cast<const SortPair<T>*>(v1); const SortPair<T>* p2 = reinterpret_cast<const SortPair<T>*>(v2); if (p2->value - p1->value < 0) return -1; if (p2->value - p1->value > 0) return 1; return 0; }