ADD file via upload

master
pcrsmk28o 2 years ago
parent 56ad191aae
commit a35ef2f031

@ -0,0 +1,69 @@
#ifndef __SKIPLIST_H__
#define __SKIPLIST_H__
#include <stdlib.h>
#define SKIPLIST_ALLOC_MEM(size) malloc((size))
#define SKIPLIST_FREE_MEM(ptr) free((ptr))
#define SKIPLIST_RAND() rand()
#define SKIPLIST_RAND_MAX RAND_MAX
enum SKIPLIST_ELOG{
SKIPLISTOK,
SKIPLISTOK_EXIST = SKIPLISTOK,
SKIPLISTERR,
SKIPLISTERR_PARAM,
SKIPLISTERR_POINTR,
SKIPLISTERR_REEXIST,
SKIPLISTERR_NOEXIST,
};
typedef struct skiplist_t skiplist_t;
typedef struct skiplist_node_t skiplist_node_t;
typedef struct skiplist_level_t skiplist_level_t;
typedef double skiplist_probability_t;
typedef skiplist_node_t* skiplist_iterator_t;
typedef int (*skiplist_cmp)(void* key,void* skiplist_data);
typedef unsigned int skiplist_size_t;
int skiplist_create(skiplist_t** sl,skiplist_probability_t probability,skiplist_cmp cmp);
int skiplist_size(skiplist_t* sl,skiplist_size_t* size);
int skiplist_getcmp(skiplist_t* sl,skiplist_cmp* cmp);
int skiplist_insert(skiplist_t* sl,void* key,void* data);
int skiplist_erase(skiplist_t* sl,void* key,void** retdata);
int skiplist_exist(skiplist_t* sl,void* key,void** retdata);
int skiplist_update(skiplist_t* sl,void* oldkey,void* newkey,void* newdata,void** retdata);
int skiplist_destroy(skiplist_t** sl);
int skiplist_begin(skiplist_t* sl,skiplist_iterator_t* it);
int skiplist_end(skiplist_t* sl,skiplist_iterator_t* it);
int skiplist_iterator_create(skiplist_iterator_t* it);
int skiplist_iterator_equal(skiplist_iterator_t* it1,skiplist_iterator_t* it2);
void skiplist_iterator_assign(skiplist_iterator_t* dit,const skiplist_iterator_t* sit);
const void* skiplist_iterator_value(skiplist_iterator_t* it);
void skiplist_iterator_next(skiplist_iterator_t* it);
void skiplist_iterator_prev(skiplist_iterator_t* it);
void skiplist_iterator_destroy(skiplist_iterator_t* it);
#endif
Loading…
Cancel
Save