#include "statistc.h"
#include <cstring>
#include <cmath>
#include <cstdlib>
#include "errcode.h"
#include <tesseract/helpers.h>
#include "scrollview.h"
#include "tprintf.h"
Go to the source code of this file.
|
int32_t | choose_nth_item (int32_t index, float *array, int32_t count) |
|
int32_t | choose_nth_item (int32_t index, void *array, int32_t count, size_t size, int(*compar)(const void *, const void *)) |
|
void | swap_entries (void *array, size_t size, int32_t index1, int32_t index2) |
|
◆ choose_nth_item() [1/2]
int32_t choose_nth_item |
( |
int32_t |
index, |
|
|
float * |
array, |
|
|
int32_t |
count |
|
) |
| |
Definition at line 609 of file statistc.cpp.
610 if (buckets_ ==
nullptr) {
614 window->SetCursor(xorigin, yorigin + yscale * buckets_[0]);
615 for (
int index = 0; index < rangemax_ - rangemin_; index++) {
616 window->DrawTo(xorigin + xscale * index,
617 yorigin + yscale * buckets_[index]);
633 int32_t prev_greater;
641 if (array[0] < array[1]) {
642 return index >= 1 ? 1 : 0;
645 return index >= 1 ? 0 : 1;
651 else if (index >=
count)
653 equal_count = static_cast<int32_t>(rand() %
count);
654 pivot = array[equal_count];
656 array[equal_count] = array[0];
658 prev_greater =
count;
660 for (next_sample = 1; next_sample < prev_greater;) {
661 sample = array[next_sample];
664 array[next_lesser++] =
sample;
667 else if (
sample > pivot) {
◆ choose_nth_item() [2/2]
int32_t choose_nth_item |
( |
int32_t |
index, |
|
|
void * |
array, |
|
|
int32_t |
count, |
|
|
size_t |
size, |
|
|
int(*)(const void *, const void *) |
compar |
|
) |
| |
Definition at line 675 of file statistc.cpp.
702 int32_t prev_greater;
709 if (compar (array, static_cast<char *>(array) + size) < 0) {
710 return index >= 1 ? 1 : 0;
713 return index >= 1 ? 0 : 1;
718 else if (index >=
count)
720 pivot = static_cast<int32_t>(rand () %
count);
723 prev_greater =
count;
725 for (next_sample = 1; next_sample < prev_greater;) {
727 compar (static_cast<char *>(array) + size * next_sample,
728 static_cast<char *>(array) + size * next_lesser);
◆ swap_entries()
void swap_entries |
( |
void * |
array, |
|
|
size_t |
size, |
|
|
int32_t |
index1, |
|
|
int32_t |
index2 |
|
) |
| |
Definition at line 735 of file statistc.cpp.
742 if (index < next_lesser)
744 else if (index < prev_greater)
748 static_cast<char *>(array) + size * prev_greater,
749 count - prev_greater, size,
750 compar) + prev_greater;