43#define HEAP_CHUNK_DEFAULT_NUM \
44 uint(MEM_SIZE_OPTIMAL((1 << 16) - sizeof(HeapNode_Chunk)) / sizeof(HeapNode))
63#define HEAP_PARENT(i) (((i) - 1) >> 1)
64#define HEAP_LEFT(i) (((i) << 1) + 1)
65#define HEAP_RIGHT(i) (((i) << 1) + 2)
66#define HEAP_COMPARE(a, b) ((a)->value < (b)->value)
69# define HEAP_EQUALS(a, b) ((a)->value == (b)->value)
134 chunk->
prev = chunk_prev;
153 node = &chunk->
buf[chunk->
size++];
176 heap->
bufsize = std::max(1u, reserve_num);
196 for (
i = 0;
i < heap->
size;
i++) {
204 chunk_prev = chunk->
prev;
218 for (
i = 0;
i < heap->
size;
i++) {
261 if (*node_p ==
nullptr) {
271 return (heap->
size == 0);
281 return heap->
tree[0];
324 if (value < node->value) {
328 else if (value > node->
value) {
337 if (value < node->value) {
341 else if (value > node->
value) {
359 if (root < heap->
size) {
370 if (r < heap->
size) {
void * BLI_heap_node_ptr(const HeapNode *heap)
bool BLI_heap_is_valid(const Heap *heap)
void BLI_heap_insert_or_update(Heap *heap, HeapNode **node_p, float value, void *ptr)
void BLI_heap_node_value_update_ptr(Heap *heap, HeapNode *node, float value, void *ptr)
BLI_INLINE void heap_swap(Heap *heap, const uint i, const uint j)
void * BLI_heap_pop_min(Heap *heap)
void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp)
static void heap_down(Heap *heap, uint i)
void BLI_heap_clear(Heap *heap, HeapFreeFP ptrfreefp)
bool BLI_heap_is_empty(const Heap *heap)
void BLI_heap_remove(Heap *heap, HeapNode *node)
static void heap_up(Heap *heap, uint i)
uint BLI_heap_len(const Heap *heap)
HeapNode * BLI_heap_top(const Heap *heap)
static void heap_node_free(Heap *heap, HeapNode *node)
HeapNode * BLI_heap_insert(Heap *heap, float value, void *ptr)
static bool heap_is_minheap(const Heap *heap, uint root)
Heap * BLI_heap_new_ex(uint reserve_num)
float BLI_heap_node_value(const HeapNode *heap)
static HeapNode * heap_node_alloc(Heap *heap)
#define HEAP_CHUNK_DEFAULT_NUM
static HeapNode_Chunk * heap_node_alloc_chunk(uint nodes_num, HeapNode_Chunk *chunk_prev)
#define HEAP_COMPARE(a, b)
void BLI_heap_node_value_update(Heap *heap, HeapNode *node, float value)
float BLI_heap_top_value(const Heap *heap)
A min-heap / priority queue ADT.
void(* HeapFreeFP)(void *ptr)
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void * MEM_mallocN(size_t len, const char *str)
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)
struct Heap::@127025266276276101366113133025016245344057331056 nodes