-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterval_map.h
More file actions
84 lines (71 loc) · 1.97 KB
/
interval_map.h
File metadata and controls
84 lines (71 loc) · 1.97 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef interval_map_h_
#define interval_map_h_
#include <stdint.h>
#include <map>
#include <vector>
class block_location
{
public:
block_location()
: sid(0)
, bid(0) {}
~block_location() {};
public:
uint64_t sid;
uint64_t bid;
};
class slice
{
public:
slice()
: location()
, offset()
, length() {}
~slice() {};
public:
block_location location;
unsigned int offset;
unsigned int length;
};
class interval_map
{
public:
interval_map();
~interval_map();
private:
interval_map(const interval_map&);
private:
void insert_contained (
unsigned int block_start_address,
unsigned int block_length,
unsigned int insert_address,
unsigned int insert_length);
void insert_right(
unsigned int block_start_address,
unsigned int insert_address);
void insert_left(
unsigned int block_start_address,
unsigned int block_length,
unsigned int insert_address,
unsigned int insert_length);
void insert_overwrite_interval(
unsigned int block_start_address);
void insert_interval(
unsigned int insert_address,
unsigned int insert_length,
block_location insert_location);
private:
typedef std::map<unsigned int, slice> slice_map_t;
typedef std::map<unsigned int, slice>::iterator slice_iter_t;
interval_map& operator = (const interval_map&);
private:
slice_map_t slice_map;
public:
void insert(unsigned int insert_address,
unsigned int insert_length,
block_location insert_location);
std::vector<slice> get_slices
(unsigned int request_address, unsigned int request_length);
void clear();
};
#endif //interval_map_h_