Statistics
| Branch: | Revision:

peerstreamer-src / src / ord_set.h @ 58fb2cdc

History | View | Annotate | Download (1.04 KB)

1 4a486a01 Luca Baldesi
/*
2
 *
3
 *  copyright (c) 2017 luca baldesi
4
 *
5
 */
6
7
#ifndef __ORD_SET__
8
#define __ORD_SET__
9
10
#define ORD_SET_INC_SIZE 10
11
12
#include<stdint.h>
13
14 b87dc7a2 Luca Baldesi
#define ord_set_for_each(iter, set)\
15
        for((iter) = NULL; ((iter) = ord_set_iter((set), (iter)));)
16
17 4a486a01 Luca Baldesi
typedef uint32_t ord_set_size;
18
19
typedef int8_t (*cmp_func_t)(const void *, const void *);
20
21
struct ord_set;
22
23
struct ord_set * ord_set_new(ord_set_size size, cmp_func_t cmp);
24
25
void ord_set_destroy(struct ord_set ** os, uint8_t free_elements);
26
27
/* ord_set_insert
28
 * if element el is present it is overridden if override = 1
29
 * it returns the element in the set for the given equivalence class
30
 */
31
void * ord_set_insert(struct ord_set * os, void * el, uint8_t override);
32
33
const void * ord_set_iter(const struct ord_set * os, const void * iter);
34
35
ord_set_size ord_set_length(const struct ord_set * os);
36
37 8f5b2a1b Luca Baldesi
const void * ord_set_find(const struct ord_set * os, const void * el);
38
39
uint8_t ord_set_remove(struct ord_set * os, const void * el, uint8_t free_element);
40
41 4d6f8fd5 Luca Baldesi
int8_t ord_set_dummy_cmp(const void * p1, const void * p2);
42
43 4a486a01 Luca Baldesi
#endif