25#define HEAP_PARENT(i) (((i)-1) >> 1)
53 uint8_t *
const tree_buf = (uint8_t *)heap->
tree;
55# define OFFSET(i) (i * uint(sizeof(HeapSimpleNode)))
56# define NODE(offset) (*(HeapSimpleNode *)(tree_buf + (offset)))
61# define NODE(i) tree[i]
64#define HEAP_LEFT_OFFSET(i) (((i) << 1) + OFFSET(1))
70 float active_val =
init->value;
71 void *active_ptr =
init->ptr;
76 NODE(
i).value = active_val;
103 NODE(
i).value = active_val;
107 NODE(
i).ptr = active_ptr;
111#undef HEAP_LEFT_OFFSET
121 if (active_val >= tree[p].value) {
129 tree[
i].
value = active_val;
130 tree[
i].
ptr = active_ptr;
144 heap->
bufsize = std::max(1u, reserve_num);
190 return (heap->
size == 0);
#define HEAP_LEFT_OFFSET(i)
static void heapsimple_up(HeapSimple *heap, uint i, float active_val, void *active_ptr)
static void heapsimple_down(HeapSimple *heap, uint start_i, const HeapSimpleNode *init)
A min-heap / priority queue ADT.
HeapSimple * BLI_heapsimple_new(void) ATTR_WARN_UNUSED_RESULT
void BLI_heapsimple_clear(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1)
void BLI_heapsimple_free(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1)
HeapSimple * BLI_heapsimple_new_ex(unsigned int reserve_num) ATTR_WARN_UNUSED_RESULT
float BLI_heapsimple_top_value(const HeapSimple *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_heapsimple_pop_min(HeapSimple *heap) ATTR_NONNULL(1)
bool BLI_heapsimple_is_empty(const HeapSimple *heap) ATTR_NONNULL(1)
uint BLI_heapsimple_len(const HeapSimple *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void(*) HeapSimpleFreeFP(void *ptr)
void BLI_heapsimple_insert(HeapSimple *heap, float value, void *ptr) ATTR_NONNULL(1)
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
#define MEM_reallocN(vmemh, len)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)