#include "statistc.h"
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include "helpers.h"
#include "scrollview.h"
#include "tprintf.h"
Go to the source code of this file.
|
inT32 | choose_nth_item (inT32 index, float *array, inT32 count) |
|
inT32 | choose_nth_item (inT32 index, void *array, inT32 count, size_t size, int(*compar)(const void *, const void *)) |
|
void | swap_entries (void *array, size_t size, inT32 index1, inT32 index2) |
|
◆ choose_nth_item() [1/2]
Definition at line 636 of file statistc.cpp.
647 if (array[0] < array[1]) {
648 return index >= 1 ? 1 : 0;
651 return index >= 1 ? 0 : 1;
657 else if (index >=
count)
660 pivot = array[equal_count];
662 array[equal_count] = array[0];
664 prev_greater =
count;
666 for (next_sample = 1; next_sample < prev_greater;) {
667 sample = array[next_sample];
668 if (sample < pivot) {
670 array[next_lesser++] = sample;
673 else if (sample > pivot) {
676 array[next_sample] = array[prev_greater];
677 array[prev_greater] = sample;
684 for (next_sample = next_lesser; next_sample < prev_greater;)
685 array[next_sample++] = pivot;
686 if (index < next_lesser)
688 else if (index < prev_greater)
692 array + prev_greater,
693 count - prev_greater) + prev_greater;
inT32 choose_nth_item(inT32 index, float *array, inT32 count)
◆ choose_nth_item() [2/2]
inT32 choose_nth_item |
( |
inT32 |
index, |
|
|
void * |
array, |
|
|
inT32 |
count, |
|
|
size_t |
size, |
|
|
int(*)(const void *, const void *) |
compar |
|
) |
| |
Definition at line 703 of file statistc.cpp.
715 if (compar (array, (
char *) array + size) < 0) {
716 return index >= 1 ? 1 : 0;
719 return index >= 1 ? 0 : 1;
724 else if (index >=
count)
729 prev_greater =
count;
731 for (next_sample = 1; next_sample < prev_greater;) {
733 compar ((
char *) array + size * next_sample,
734 (
char *) array + size * next_lesser);
736 swap_entries (array, size, next_lesser++, next_sample++);
739 else if (result > 0) {
748 if (index < next_lesser)
750 else if (index < prev_greater)
754 (
char *) array + size * prev_greater,
755 count - prev_greater, size,
756 compar) + prev_greater;
inT32 choose_nth_item(inT32 index, float *array, inT32 count)
void swap_entries(void *array, size_t size, inT32 index1, inT32 index2)
◆ swap_entries()
void swap_entries |
( |
void * |
array, |
|
|
size_t |
size, |
|
|
inT32 |
index1, |
|
|
inT32 |
index2 |
|
) |
| |
Definition at line 764 of file statistc.cpp.
773 ptr1 =
static_cast<char *
>(array) + index1 * size;
774 ptr2 =
static_cast<char *
>(array) + index2 * size;
775 for (count = 0; count < size; count++) {