29 #define MIN_CAPACITY 16 51 cv::AutoBuffer<char> tmp(heap->
el_sz);
64 void **pp = (
void**) heap->
data;
78 if (el_sz ==
sizeof(
void*))
94 if (heap->
alloc >= capacity)
97 int newcap = heap->
alloc;
99 while (newcap < capacity) {
108 heap->
values = (
float*)realloc(heap->
values, newcap *
sizeof(
float));
109 heap->
data = (
char*)realloc(heap->
data, newcap * heap->
el_sz);
110 heap->
alloc = newcap;
117 int idx = heap->
size;
126 int parent = (idx - 1) / 2;
129 if (heap->
values[parent] >= v)
133 heap->
swap(heap, idx, parent);
143 if (idx >= heap->
size)
156 if (idx == heap->
size)
168 float parent_score = heap->
values[idx];
171 while (parent < heap->
size) {
173 int left = 2*parent + 1;
174 int right = left + 1;
178 float left_score = (left < heap->
size) ? heap->
values[left] : -INFINITY;
179 float right_score = (right < heap->size) ? heap->
values[right] : -INFINITY;
184 if (parent_score >= left_score && parent_score >= right_score)
188 if (left_score >= right_score) {
189 CV_Assert(left < heap->size);
190 heap->
swap(heap, parent, left);
194 CV_Assert(right < heap->size);
195 heap->
swap(heap, parent, right);
static void _zmaxheap_ensure_capacity(zmaxheap_t *heap, int capacity)
static void _swap_pointer(zmaxheap_t *heap, int a, int b)
zmaxheap_t * zmaxheap_create(size_t el_sz)
static int zmaxheap_remove_index(zmaxheap_t *heap, int idx, void *p, float *v)
geometry_msgs::TransformStamped t
void(* swap)(zmaxheap_t *heap, int a, int b)
static void _swap_default(zmaxheap_t *heap, int a, int b)
int zmaxheap_remove_max(zmaxheap_t *heap, void *p, float *v)
void zmaxheap_add(zmaxheap_t *heap, void *p, float v)
void zmaxheap_destroy(zmaxheap_t *heap)