#include <stdio.h>
#include "host.h"
#include "kdpair.h"
#include "scrollview.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 638 of file statistc.cpp.
649 if (array[0] < array[1]) {
650 return index >= 1 ? 1 : 0;
653 return index >= 1 ? 0 : 1;
659 else if (index >=
count)
662 pivot = array[equal_count];
664 array[equal_count] = array[0];
666 prev_greater =
count;
668 for (next_sample = 1; next_sample < prev_greater;) {
669 sample = array[next_sample];
672 array[next_lesser++] =
sample;
675 else if (
sample > pivot) {
678 array[next_sample] = array[prev_greater];
679 array[prev_greater] =
sample;
686 for (next_sample = next_lesser; next_sample < prev_greater;)
687 array[next_sample++] = pivot;
688 if (index < next_lesser)
690 else if (index < prev_greater)
694 array + prev_greater,
695 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 705 of file statistc.cpp.
717 if (compar (array, (
char *) array + size) < 0) {
718 return index >= 1 ? 1 : 0;
721 return index >= 1 ? 0 : 1;
726 else if (index >=
count)
731 prev_greater =
count;
733 for (next_sample = 1; next_sample < prev_greater;) {
735 compar ((
char *) array + size * next_sample,
736 (
char *) array + size * next_lesser);
738 swap_entries (array, size, next_lesser++, next_sample++);
741 else if (result > 0) {
750 if (index < next_lesser)
752 else if (index < prev_greater)
756 (
char *) array + size * prev_greater,
757 count - prev_greater, size,
758 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)
◆ swap_entries()
void swap_entries |
( |
void * |
array, |
|
|
size_t |
size, |
|
|
inT32 |
index1, |
|
|
inT32 |
index2 |
|
) |
| |
Definition at line 766 of file statistc.cpp.
775 ptr1 =
reinterpret_cast<char*
>(array) + index1 * size;
776 ptr2 =
reinterpret_cast<char*
>(array) + index2 * size;