-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.hpp
More file actions
46 lines (30 loc) · 837 Bytes
/
node.hpp
File metadata and controls
46 lines (30 loc) · 837 Bytes
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
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <stdexcept>
namespace text_editor
{
class rope_node
{
public:
using handle = std::unique_ptr<rope_node>;
rope_node(handle l, handle r);
rope_node(const std::string &str);
rope_node(const rope_node &);
size_t getLength(void) const;
char getCharByIndex(size_t) const;
std::string getSubstring(size_t start, size_t len) const;
std::string treeToString(void) const;
friend std::pair<handle, handle> splitAt(handle, size_t);
size_t getDepth(void) const;
void getLeaves(std::vector<rope_node *> &v);
void print_tree(std::ostream &out, int level) const;
private:
size_t weight_;
handle left_;
handle right_;
std::string fragment_;
bool isLeaf(void) const;
};
}