-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheditor.h
More file actions
85 lines (73 loc) · 1.44 KB
/
Copy patheditor.h
File metadata and controls
85 lines (73 loc) · 1.44 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
85
#ifndef _EDITOR_H_
#define _EDITOR_H_
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
#include "node.h"
//Double-linked list link node with freelist support
class Link : public node{
private:
node* head;
node* tail;
node* fence;
int leftcnt;
int rightcnt;
public:
Link()
{
init();
}
~Link() {
removeall(); //destructor
}
void clear(){
removeall();
init();
}
bool insert(int num,const string& item);
bool deleteoneline(int num);
bool append(const string& item);
bool remove(string& it);
bool changeline(int num,string& str);
bool changeonelinecharacter(int num,string& str);
bool findinallstring(string& str);
bool setStart();
bool setEnd();
void prev();
void next1()
{
if (fence!=tail) { //don't move fence if right empty
fence=fence->next;
rightcnt--;
leftcnt++;
}
}
int leftlength() const{return leftcnt;}
int rightlength() const{return rightcnt;}
int longlength() ;
bool displayoneline();
bool findappointstring(string str);
bool setpos(int pos);
bool getValue(string& it) const {
if(rightlength()==0)
return false;
it=fence->next->element;
return true;
}
void print() const;
void init() ;
void removeall() {
while(head != NULL)
{
fence = head;
head = head->next;
delete fence;
}
}
//input the data to the inputfile.
void save_to_file(string filename);
//read the data from the file
void read_from_infile(string filename);
};
#endif