#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) |
|
Definition at line 642 of file statistc.cpp.
653 if (array[0] < array[1]) {
654 return index >= 1 ? 1 : 0;
657 return index >= 1 ? 0 : 1;
663 else if (index >=
count)
666 pivot = array[equal_count];
668 array[equal_count] = array[0];
670 prev_greater =
count;
672 for (next_sample = 1; next_sample < prev_greater;) {
673 sample = array[next_sample];
674 if (sample < pivot) {
676 array[next_lesser++] = sample;
679 else if (sample > pivot) {
682 array[next_sample] = array[prev_greater];
683 array[prev_greater] = sample;
690 for (next_sample = next_lesser; next_sample < prev_greater;)
691 array[next_sample++] = pivot;
692 if (index < next_lesser)
694 else if (index < prev_greater)
698 array + prev_greater,
699 count - prev_greater) + prev_greater;
inT32 choose_nth_item(inT32 index, float *array, inT32 count)
inT32 choose_nth_item |
( |
inT32 |
index, |
|
|
void * |
array, |
|
|
inT32 |
count, |
|
|
size_t |
size, |
|
|
int(*)(const void *, const void *) |
compar |
|
) |
| |
Definition at line 709 of file statistc.cpp.
721 if (compar (array, (
char *) array + size) < 0) {
722 return index >= 1 ? 1 : 0;
725 return index >= 1 ? 0 : 1;
730 else if (index >=
count)
735 prev_greater =
count;
737 for (next_sample = 1; next_sample < prev_greater;) {
739 compar ((
char *) array + size * next_sample,
740 (
char *) array + size * next_lesser);
742 swap_entries (array, size, next_lesser++, next_sample++);
745 else if (result > 0) {
754 if (index < next_lesser)
756 else if (index < prev_greater)
760 (
char *) array + size * prev_greater,
761 count - prev_greater, size,
762 compar) + prev_greater;
void swap_entries(void *array, size_t size, inT32 index1, inT32 index2)
inT32 choose_nth_item(inT32 index, float *array, inT32 count)
void swap_entries |
( |
void * |
array, |
|
|
size_t |
size, |
|
|
inT32 |
index1, |
|
|
inT32 |
index2 |
|
) |
| |
Definition at line 770 of file statistc.cpp.
779 ptr1 =
reinterpret_cast<char*
>(array) + index1 * size;
780 ptr2 =
reinterpret_cast<char*
>(array) + index2 * size;
781 for (count = 0; count < size; count++) {