Nagios
4.3.4
Dev docs for Nagios core and neb-module hackers
|
Skiplist library functions. More...
#include "lnag-utils.h"
Go to the source code of this file.
#define | SKIPLIST_OK 0 |
A ok. | |
#define | SKIPLIST_ERROR_ARGS 1 |
Bad arguments. | |
#define | SKIPLIST_ERROR_MEMORY 2 |
Memory error. | |
#define | SKIPLIST_ERROR_DUPLICATE 3 |
Trying to insert non-unique item. | |
typedef struct skiplist_struct | skiplist |
unsigned long | skiplist_num_items (skiplist *list) |
Return number of items currently in the skiplist. More... | |
skiplist * | skiplist_new (int max_levels, float level_probability, int allow_duplicates, int append_duplicates, int(*compare_function)(void *, void *)) |
Create a new skiplist. More... | |
int | skiplist_insert (skiplist *list, void *data) |
Insert an item into a skiplist. More... | |
int | skiplist_empty (skiplist *list) |
Empty the skiplist of all data. More... | |
int | skiplist_free (skiplist **list) |
Free all nodes (but not all data) in a skiplist This is similar to skiplist_empty(), but also free()'s the head node. More... | |
void * | skiplist_peek (skiplist *list) |
Get the first item in the skiplist. More... | |
void * | skiplist_pop (skiplist *list) |
Pop the first item from the skiplist. More... | |
void * | skiplist_get_first (skiplist *list, void **node_ptr) |
Get first node of skiplist. More... | |
void * | skiplist_get_next (void **node_ptr) |
Get next item from node_ptr. More... | |
void * | skiplist_find_first (skiplist *list, void *data, void **node_ptr) |
Find first entry in skiplist matching data. More... | |
void * | skiplist_find_next (skiplist *list, void *data, void **node_ptr) |
Find next entry in skiplist matching data. More... | |
int | skiplist_delete (skiplist *list, void *data) |
Delete all items matching 'data' from skiplist. More... | |
int | skiplist_delete_first (skiplist *list, void *data) |
Delete first item matching 'data' from skiplist. More... | |
int | skiplist_delete_node (skiplist *list, void *node_ptr) |
Delete a particular node from the skiplist. More... | |
Skiplist library functions.
int skiplist_delete | ( | skiplist * | list, |
void * | data | ||
) |
Delete all items matching 'data' from skiplist.
list | The list to delete from |
data | Comparison object used to find the real node |
int skiplist_delete_first | ( | skiplist * | list, |
void * | data | ||
) |
Delete first item matching 'data' from skiplist.
list | The list to delete from |
data | Comparison object used to search the list |
int skiplist_delete_node | ( | skiplist * | list, |
void * | node_ptr | ||
) |
Delete a particular node from the skiplist.
list | The list to search |
node_ptr | The node to delete |
int skiplist_empty | ( | skiplist * | list | ) |
Empty the skiplist of all data.
list | The list to empty |
void* skiplist_find_first | ( | skiplist * | list, |
void * | data, | ||
void ** | node_ptr | ||
) |
Find first entry in skiplist matching data.
list | The list to search | |
data | Comparison object used to search | |
[out] | node_ptr | State variable for future lookups with skiplist_find_next() |
void* skiplist_find_next | ( | skiplist * | list, |
void * | data, | ||
void ** | node_ptr | ||
) |
Find next entry in skiplist matching data.
list | The list to search | |
data | The data to compare against | |
[out] | node_ptr | State var primed from earlier call to skiplist_find_next() or skiplist_find_first() |
int skiplist_free | ( | skiplist ** | list | ) |
Free all nodes (but not all data) in a skiplist This is similar to skiplist_empty(), but also free()'s the head node.
list | The list to free |
void* skiplist_get_first | ( | skiplist * | list, |
void ** | node_ptr | ||
) |
Get first node of skiplist.
list | The list to search | |
[out] | node_ptr | State variable for skiplist_get_next() |
void* skiplist_get_next | ( | void ** | node_ptr | ) |
Get next item from node_ptr.
[out] | node_ptr | State variable primed from an earlier call to skiplist_get_first() or skiplist_get_next() |
int skiplist_insert | ( | skiplist * | list, |
void * | data | ||
) |
Insert an item into a skiplist.
list | The list to insert to |
data | The data to insert |
skiplist* skiplist_new | ( | int | max_levels, |
float | level_probability, | ||
int | allow_duplicates, | ||
int | append_duplicates, | ||
int(*)(void *, void *) | compare_function | ||
) |
Create a new skiplist.
max_levels | Number of "ups" we have. This Should be kept close to lg2 of the number of items to store. |
level_probability | Ignored |
allow_duplicates | Allow duplicates in this list |
append_duplicates | Append rather than prepend duplicates |
compare_function | Comparison function for data entries |
unsigned long skiplist_num_items | ( | skiplist * | list | ) |
Return number of items currently in the skiplist.
list | The list to investigate |
void* skiplist_peek | ( | skiplist * | list | ) |
Get the first item in the skiplist.
list | The list to peek into |
void* skiplist_pop | ( | skiplist * | list | ) |
Pop the first item from the skiplist.
list | The list to pop from |