Piojo Heap (min-heap) implementation.
Returns TRUE if e1 is less or equal to e2, FALSE otherwise.
Allocates a new heap. Uses default allocator.
- Parameters
-
[in] | leq | Entry comparison function. |
- Returns
- New heap.
Allocates a new heap.
- Parameters
-
[in] | leq | Entry comparison function. |
[in] | allocator | Allocator to be used. |
- Returns
- New heap.
void piojo_heap_clear |
( |
piojo_heap_t * |
heap | ) |
|
Deletes all entries in heap.
- Parameters
-
[out] | heap | Heap being cleared. |
bool piojo_heap_contain_p |
( |
piojo_opaque_t |
data, |
|
|
const piojo_heap_t * |
heap |
|
) |
| |
Searches entry in heap.
- Parameters
-
[in] | data | Entry value. |
[in] | heap | |
- Returns
- TRUE if entry is in heap, FALSE otherwise.
piojo_heap_t* piojo_heap_copy |
( |
const piojo_heap_t * |
heap | ) |
|
Copies heap and all its entries.
- Parameters
-
[in] | heap | Heap being copied. |
- Returns
- New heap.
Decreases existing entry key.
- Parameters
-
[in] | data | Entry value. |
[out] | heap | Heap being modified. |
void piojo_heap_free |
( |
const piojo_heap_t * |
heap | ) |
|
Frees heap and all its entries.
- Parameters
-
[in] | heap | Heap being freed. |
Reads the minimum entry according to key.
- Parameters
-
- Returns
- Entry value.
void piojo_heap_pop |
( |
piojo_heap_t * |
heap | ) |
|
Deletes the minimum entry according to key.
- Parameters
-
Inserts a new entry.
- Warning
- data can't be inserted more than once.
- Parameters
-
[in] | data | Entry value. |
[out] | heap | Heap being modified. |
void piojo_heap_resize |
( |
size_t |
ecount, |
|
|
piojo_heap_t * |
heap |
|
) |
| |
Expands or shrinks allocated memory for ecount entries.
- Parameters
-
[in] | ecount | Must be equal or greater than the current size. |
[out] | heap | Heap being modified. |
size_t piojo_heap_size |
( |
const piojo_heap_t * |
heap | ) |
|
Returns number of entries.
- Parameters
-
- Returns
- Number of entries in heap.
const size_t piojo_heap_sizeof |