]>
Commit | Line | Data |
---|---|---|
6c2705cd LR |
1 | /* Copyright (C) 2016 Hewlett Packard Enterprise Development LP |
2 | * All Rights Reserved. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may | |
5 | * not use this file except in compliance with the License. You may obtain | |
6 | * a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
13 | * License for the specific language governing permissions and limitations | |
14 | * under the License. | |
15 | */ | |
16 | ||
17 | #ifndef LIB_SKIPLIST_H_ | |
18 | #define LIB_SKIPLIST_H_ | |
19 | ||
20 | #include <stdbool.h> | |
21 | #include <stdint.h> | |
22 | #include <stdlib.h> | |
23 | ||
24 | typedef int (skiplist_comparator)(const void *a, const void *b, | |
25 | const void *conf); | |
26 | ||
27 | struct skiplist_node; | |
28 | ||
29 | struct skiplist; | |
30 | ||
31 | #define SKIPLIST_FOR_EACH (SKIPLIST_NODE, SKIPLIST) \ | |
32 | for (SKIPLIST_NODE = skiplist_first(SKIPLIST); \ | |
33 | SKIPLIST_NODE; \ | |
34 | SKIPLIST_NODE = skiplist_next(SKIPLIST_NODE)) | |
35 | ||
36 | struct skiplist *skiplist_create(skiplist_comparator *object_comparator, | |
37 | void *configuration); | |
38 | void skiplist_insert(struct skiplist *sl, const void *object); | |
39 | void *skiplist_delete(struct skiplist *sl, const void *object); | |
40 | struct skiplist_node *skiplist_find(struct skiplist *sl, const void *value); | |
41 | void *skiplist_get_data(struct skiplist_node *node); | |
42 | uint32_t skiplist_get_size(struct skiplist *sl); | |
43 | struct skiplist_node *skiplist_forward_to(struct skiplist *sl, | |
44 | const void *value); | |
45 | struct skiplist_node *skiplist_first(struct skiplist *sl); | |
46 | struct skiplist_node *skiplist_next(struct skiplist_node *node); | |
47 | void skiplist_destroy(struct skiplist *sl, void (*func)(void *)); | |
48 | ||
49 | #endif /* LIB_SKIPLIST_H_ */ |