summaryrefslogtreecommitdiff
path: root/include/linux/skip_lists.h
blob: 84c550655e3934217778e3687eb7663f035e1925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef _LINUX_SKIP_LISTS_H
#define _LINUX_SKIP_LISTS_H
typedef u64 keyType;
typedef void *valueType;

typedef struct nodeStructure skiplist_node;

struct nodeStructure {
	int level;	/* Levels in this structure */
	keyType key;
	valueType value;
	skiplist_node *next[16];
	skiplist_node *prev[16];
};

typedef struct listStructure {
	int entries;
	int level;	/* Maximum level of the list
			(1 more than the number of levels in the list) */
	skiplist_node *header; /* pointer to header */
} skiplist;

void skiplist_init(skiplist_node *slnode);
skiplist *new_skiplist(skiplist_node *slnode);
void free_skiplist(skiplist *l);
void skiplist_node_init(skiplist_node *node);
void skiplist_insert(skiplist *l, skiplist_node *node, keyType key, valueType value, unsigned int randseed);
void skiplist_delete(skiplist *l, skiplist_node *node);

static inline bool skiplist_node_empty(skiplist_node *node) {
	return (!node->next[0]);
}
#endif /* _LINUX_SKIP_LISTS_H */