-
Notifications
You must be signed in to change notification settings - Fork 0
/
rope.h
61 lines (36 loc) · 1.06 KB
/
rope.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
53
54
55
56
57
58
59
60
61
#ifndef __ROPE__
#define __ROPE__
#define EMPTY ""
typedef struct RopeNode RopeNode;
struct RopeNode {
RopeNode* left;
RopeNode* right;
const char* str;
int weight;
};
typedef struct RopeTree RopeTree;
struct RopeTree {
RopeNode* root;
};
typedef struct SplitPair SplitPair;
struct SplitPair {
RopeNode* left;
RopeNode* right;
};
RopeNode* makeRopeNode(const char* str);
RopeTree* makeRopeTree(RopeNode* root);
void printRopeNode(RopeNode* rn);
void printRopeTree(RopeTree* rt);
void debugRopeNode(RopeNode* rn, int indent);
RopeTree* concat(RopeTree* rt1, RopeTree* rt2);
RopeNode* concat_n(RopeNode* rn1, RopeNode* rn2);
char indexRope(RopeTree* rt, int idx);
char __indexRope(RopeNode *rn, int idx);
char* search(RopeTree* rt, int start, int end);
SplitPair split(RopeTree* rt, int idx);
void split_one(RopeNode* rn, int *idx);
RopeTree* insert(RopeTree* rt, int idx, const char* str);
RopeTree* delete(RopeTree* rt, int start, int len);
RopeNode *copy_tree(RopeNode *rn);
char* my_strdup(const char* str);
#endif // __ROPE__