]>
git.proxmox.com Git - ovs.git/blob - lib/skiplist.h
1 /* Copyright (C) 2016 Hewlett Packard Enterprise Development LP
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 #ifndef LIB_SKIPLIST_H_
18 #define LIB_SKIPLIST_H_
24 typedef int (skiplist_comparator
)(const void *a
, const void *b
,
31 #define SKIPLIST_FOR_EACH (SKIPLIST_NODE, SKIPLIST) \
32 for (SKIPLIST_NODE = skiplist_first(SKIPLIST); \
34 SKIPLIST_NODE = skiplist_next(SKIPLIST_NODE))
36 struct skiplist
*skiplist_create(skiplist_comparator
*object_comparator
,
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
,
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 *));
49 #endif /* LIB_SKIPLIST_H_ */