summaryrefslogtreecommitdiff
path: root/mtable.h
blob: 573f3e2198510cdf27b76e59c341cf1874825326 (plain) (blame)
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
#ifndef __MTABLE_H
#define __MTABLE_H

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include "darray.h"
#include "debug.h"

typedef struct mt_range {
	//range postiont start end
	unsigned long start;
	unsigned long end;
	//cmp array start end
	void *cmp;
	int cmp_sz;
	//note string
	void *val;
	int val_sz;
} mt_range;

typedef struct mt_table {
	darray *table;
} mt_table;

mt_table* mt_create();
int mt_add( mt_table *mt, mt_range *rng );
mt_range* mt_search( mt_table *mt, int pos );
int mt_print( mt_table *mt );
void mt_destroy( mt_table *mt );

#define mt_size(MT_TABLE) (darr_end((MT_TABLE)->table))
#define mt_get(MT_TABLE,X) (darr_get((MT_TABLE)->table,X))

#endif