cdcontainers
0.1.1
Library of data containers and collections for C programming language.
|
The cdc_pairing_heap is a struct and functions that provide a pairing heap. More...
#include <cdcontainers/common.h>
#include <cdcontainers/status.h>
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | cdc_pairing_heap_node |
The cdc_pairing_heap_node struct. More... | |
struct | cdc_pairing_heap |
The cdc_pairing_heap struct. More... | |
struct | cdc_pairing_heap_iter |
The cdc_pairing_heap_iter struct. More... | |
Functions | |
enum cdc_stat | cdc_pairing_heap_ctor (struct cdc_pairing_heap **h, struct cdc_data_info *info) |
Constructs an empty pairing heap. More... | |
enum cdc_stat | cdc_pairing_heap_ctorl (struct cdc_pairing_heap **h, struct cdc_data_info *info,...) |
Constructs a pairing heap, initialized by an arbitrary number of pointers. The last item must be NULL. More... | |
enum cdc_stat | cdc_pairing_heap_ctorv (struct cdc_pairing_heap **h, struct cdc_data_info *info, va_list args) |
Constructs a pairing heap, initialized by args. The last item must be NULL. More... | |
void | cdc_pairing_heap_dtor (struct cdc_pairing_heap *h) |
Destroys the pairing heap. More... | |
static void * | cdc_pairing_heap_top (struct cdc_pairing_heap *h) |
Returns a pointer to the pairing heap's top item. This function assumes that the pairing heap isn't empty. More... | |
static size_t | cdc_pairing_heap_size (struct cdc_pairing_heap *h) |
Returns the number of items in the pairing heap. More... | |
static bool | cdc_pairing_heap_empty (struct cdc_pairing_heap *h) |
Returns true if the pairing heap has size 0; otherwise returns false. More... | |
enum cdc_stat | cdc_pairing_heap_extract_top (struct cdc_pairing_heap *h) |
Extracts the top item from the pairing heap. This function assumes that the pairing heap isn't empty. More... | |
enum cdc_stat | cdc_pairing_heap_riinsert (struct cdc_pairing_heap *h, void *key, struct cdc_pairing_heap_iter *ret) |
Inserts element key to the pairing heap. Write an iterator pointing to a new element in the ret. More... | |
static enum cdc_stat | cdc_pairing_heap_insert (struct cdc_pairing_heap *h, void *key) |
Inserts element key to the pairing heap. More... | |
void | cdc_pairing_heap_change_key (struct cdc_pairing_heap *h, struct cdc_pairing_heap_iter *pos, void *key) |
Changes the item key on the pos position in the pairing heap. More... | |
void | cdc_pairing_heap_clear (struct cdc_pairing_heap *h) |
Removes all the elements from the pairing heap. More... | |
void | cdc_pairing_heap_swap (struct cdc_pairing_heap *a, struct cdc_pairing_heap *b) |
Swaps pairing heaps a and b. This operation is very fast and never fails. More... | |
void | cdc_pairing_heap_merge (struct cdc_pairing_heap *h, struct cdc_pairing_heap *other) |
Merges two heaps. In the heap h will be the result of the merger, and the heap other will remain empty. More... | |
bool | cdc_pairing_heap_is_heap (struct cdc_pairing_heap *h) |
Checks the heap property. More... | |
static void * | cdc_pairing_heap_iter_data (struct cdc_pairing_heap_iter *it) |
Returns a pointer to the key of current item. More... | |
static bool | cdc_pairing_heap_iter_is_eq (struct cdc_pairing_heap_iter *it1, struct cdc_pairing_heap_iter *it2) |
Returns false if the iterator it1 equal to the iterator it2, otherwise returns false. More... | |
The cdc_pairing_heap is a struct and functions that provide a pairing heap.
enum cdc_stat cdc_pairing_heap_ctor | ( | struct cdc_pairing_heap ** | h, |
struct cdc_data_info * | info | ||
) |
Constructs an empty pairing heap.
h | - cdc_pairing_heap |
info | - cdc_data_info |
enum cdc_stat cdc_pairing_heap_ctorl | ( | struct cdc_pairing_heap ** | h, |
struct cdc_data_info * | info, | ||
... | |||
) |
Constructs a pairing heap, initialized by an arbitrary number of pointers. The last item must be NULL.
h | - cdc_pairing_heap |
info | - cdc_data_info |
enum cdc_stat cdc_pairing_heap_ctorv | ( | struct cdc_pairing_heap ** | h, |
struct cdc_data_info * | info, | ||
va_list | args | ||
) |
Constructs a pairing heap, initialized by args. The last item must be NULL.
h | - cdc_pairing_heap |
info | - cdc_data_info |
void cdc_pairing_heap_dtor | ( | struct cdc_pairing_heap * | h | ) |
Destroys the pairing heap.
h | - cdc_pairing_heap |
|
inlinestatic |
Returns a pointer to the pairing heap's top item. This function assumes that the pairing heap isn't empty.
h | - cdc_pairing_heap |
|
inlinestatic |
|
inlinestatic |
Returns true if the pairing heap has size 0; otherwise returns false.
h | - cdc_pairing_heap |
enum cdc_stat cdc_pairing_heap_extract_top | ( | struct cdc_pairing_heap * | h | ) |
Extracts the top item from the pairing heap. This function assumes that the pairing heap isn't empty.
h | - cdc_pairing_heap |
enum cdc_stat cdc_pairing_heap_riinsert | ( | struct cdc_pairing_heap * | h, |
void * | key, | ||
struct cdc_pairing_heap_iter * | ret | ||
) |
Inserts element key to the pairing heap. Write an iterator pointing to a new element in the ret.
h | a cdc_pairing_heap |
key | |
ret | - pointer to iterator where an iterator will be written indicating the inserted element |
|
inlinestatic |
Inserts element key to the pairing heap.
h | - cdc_pairing_heap |
key |
void cdc_pairing_heap_change_key | ( | struct cdc_pairing_heap * | h, |
struct cdc_pairing_heap_iter * | pos, | ||
void * | key | ||
) |
Changes the item key on the pos position in the pairing heap.
h | - cdc_pairing_heap |
pos | - iterator that indicates the item with key that you want to change |
key |
void cdc_pairing_heap_clear | ( | struct cdc_pairing_heap * | h | ) |
Removes all the elements from the pairing heap.
h | - cdc_pairing_heap |
void cdc_pairing_heap_swap | ( | struct cdc_pairing_heap * | a, |
struct cdc_pairing_heap * | b | ||
) |
Swaps pairing heaps a and b. This operation is very fast and never fails.
a | - cdc_pairing_heap |
b | - cdc_pairing_heap |
void cdc_pairing_heap_merge | ( | struct cdc_pairing_heap * | h, |
struct cdc_pairing_heap * | other | ||
) |
Merges two heaps. In the heap h will be the result of the merger, and the heap other will remain empty.
h | - cdc_pairing_heap |
other | - other cdc_pairing_heap |
bool cdc_pairing_heap_is_heap | ( | struct cdc_pairing_heap * | h | ) |
|
inlinestatic |
Returns a pointer to the key of current item.
|
inlinestatic |
Returns false if the iterator it1 equal to the iterator it2, otherwise returns false.