Blender V4.5
BLI_heap.h File Reference

A min-heap / priority queue ADT. More...

#include <stdbool.h>
#include <stddef.h>
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Typedefs

typedef struct Heap Heap
typedef struct HeapNode HeapNode
typedef void(*) HeapFreeFP(void *ptr)

Functions

HeapBLI_heap_new_ex (unsigned int reserve_num) ATTR_WARN_UNUSED_RESULT
HeapBLI_heap_new (void) ATTR_WARN_UNUSED_RESULT
void BLI_heap_clear (Heap *heap, HeapFreeFP ptrfreefp) ATTR_NONNULL(1)
void BLI_heap_free (Heap *heap, HeapFreeFP ptrfreefp) ATTR_NONNULL(1)
HeapNodeBLI_heap_insert (Heap *heap, float value, void *ptr) ATTR_NONNULL(1)
void BLI_heap_insert_or_update (Heap *heap, HeapNode **node_p, float value, void *ptr) ATTR_NONNULL(1
void void BLI_heap_remove (Heap *heap, HeapNode *node) ATTR_NONNULL(1
void void bool BLI_heap_is_empty (const Heap *heap) ATTR_NONNULL(1)
unsigned int BLI_heap_len (const Heap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
HeapNodeBLI_heap_top (const Heap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
float BLI_heap_top_value (const Heap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_heap_pop_min (Heap *heap) ATTR_NONNULL(1)
void BLI_heap_node_value_update (Heap *heap, HeapNode *node, float value) ATTR_NONNULL(1
void void BLI_heap_node_value_update_ptr (Heap *heap, HeapNode *node, float value, void *ptr) ATTR_NONNULL(1
void void float BLI_heap_node_value (const HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_heap_node_ptr (const HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool BLI_heap_is_valid (const Heap *heap)

Detailed Description

A min-heap / priority queue ADT.

Definition in file BLI_heap.h.

Typedef Documentation

◆ Heap

typedef struct Heap Heap

Definition at line 19 of file BLI_heap.h.

◆ HeapFreeFP

typedef void(*) HeapFreeFP(void *ptr)

Definition at line 22 of file BLI_heap.h.

◆ HeapNode

typedef struct HeapNode HeapNode

Definition at line 20 of file BLI_heap.h.

Function Documentation

◆ BLI_heap_clear()

◆ BLI_heap_free()

◆ BLI_heap_insert()

◆ BLI_heap_insert_or_update()

void BLI_heap_insert_or_update ( Heap * heap,
HeapNode ** node_p,
float value,
void * ptr )

◆ BLI_heap_is_empty()

◆ BLI_heap_is_valid()

bool BLI_heap_is_valid ( const Heap * heap)

Only for checking internal errors (gtest).

Definition at line 378 of file BLI_heap.cc.

References BLI_heap_is_valid(), and heap_is_minheap().

Referenced by BLI_heap_is_valid(), BLI_heap_node_value_update_ptr(), and random_heap_reinsert_helper().

◆ BLI_heap_len()

unsigned int BLI_heap_len ( const Heap * heap)

◆ BLI_heap_new()

◆ BLI_heap_new_ex()

◆ BLI_heap_node_ptr()

◆ BLI_heap_node_value()

void void float BLI_heap_node_value ( const HeapNode * heap)

◆ BLI_heap_node_value_update()

void BLI_heap_node_value_update ( Heap * heap,
HeapNode * node,
float value )

Can be used to avoid BLI_heap_remove, BLI_heap_insert calls, balancing the tree still has a performance cost, but is often much less than remove/insert, difference is most noticeable with large heaps.

References ATTR_NONNULL, and BLI_heap_node_value_update().

Referenced by BLI_heap_node_value_update(), BLI_heap_node_value_update(), BM_mesh_decimate_dissolve_ex(), colorband_init_from_table_rgba_resample(), EDBM_select_interior_faces(), random_heap_reinsert_helper(), reprioritize_join(), and TEST().

◆ BLI_heap_node_value_update_ptr()

◆ BLI_heap_pop_min()

◆ BLI_heap_remove()

◆ BLI_heap_top()

HeapNode * BLI_heap_top ( const Heap * heap)

Return the top node of the heap. This is the node with the lowest value.

Definition at line 279 of file BLI_heap.cc.

References BLI_heap_top(), and Heap::tree.

Referenced by BLI_heap_remove(), BLI_heap_top(), BM_mesh_decimate_dissolve_ex(), EDBM_select_interior_faces(), blender::geometry::p_chart_simplify_compute(), and random_heap_reinsert_helper().

◆ BLI_heap_top_value()

float BLI_heap_top_value ( const Heap * heap)

Return the value of top node of the heap. This is the node with the lowest value.

Definition at line 284 of file BLI_heap.cc.

References BLI_assert, BLI_heap_top_value(), Heap::size, Heap::tree, and HeapNode::value.

Referenced by BLI_heap_remove(), BLI_heap_top_value(), BM_mesh_decimate_collapse(), bmo_join_triangles_exec(), colorband_init_from_table_rgba_resample(), and random_heap_reinsert_helper().