]> git.proxmox.com Git - mirror_ovs.git/blame - lib/skiplist.h
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / lib / skiplist.h
CommitLineData
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
24typedef int (skiplist_comparator)(const void *a, const void *b,
25 const void *conf);
26
27struct skiplist_node;
28
29struct 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
36struct skiplist *skiplist_create(skiplist_comparator *object_comparator,
37 void *configuration);
38void skiplist_insert(struct skiplist *sl, const void *object);
39void *skiplist_delete(struct skiplist *sl, const void *object);
40struct skiplist_node *skiplist_find(struct skiplist *sl, const void *value);
41void *skiplist_get_data(struct skiplist_node *node);
42uint32_t skiplist_get_size(struct skiplist *sl);
43struct skiplist_node *skiplist_forward_to(struct skiplist *sl,
44 const void *value);
45struct skiplist_node *skiplist_first(struct skiplist *sl);
46struct skiplist_node *skiplist_next(struct skiplist_node *node);
47void skiplist_destroy(struct skiplist *sl, void (*func)(void *));
48
49#endif /* LIB_SKIPLIST_H_ */