-
Notifications
You must be signed in to change notification settings - Fork 12
/
omt.h
52 lines (38 loc) · 853 Bytes
/
omt.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Copyright (c) 2013, BohuTANG <overred.shuttler at gmail dot com>
* All rights reserved.
* Code is licensed with GPL. See COPYING.GPL file.
*
*/
#ifndef _OMT_H_
#define _OMT_H_
#include <stdint.h>
struct slice {
int size;
char *data;
};
struct omt_val {
void *val;
};
struct omt_subtree {
uint32_t idx;
};
struct omt_node {
int weight;
uint32_t nidx;
struct slice *value;
struct omt_subtree left;
struct omt_subtree right;
} __attribute__((packed));
struct omt_tree {
unsigned int capacity;
unsigned int free_idx;
struct omt_node *nodes;
struct omt_subtree root_subtree;
uint64_t status_rebalance_nums;
};
struct omt_tree *omt_new();
int omt_insert(struct omt_tree *tree, struct slice *val);
int omt_find_order(struct omt_tree *tree, struct slice *val, uint32_t *order);
void omt_free(struct omt_tree *tree);
#endif