-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.h
74 lines (48 loc) · 2.14 KB
/
file.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
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef FILE_H
#define FILE_H
#include <iostream>
#include <fstream>
#include "RBTree.h"
extern string indexFileName;
extern string dataFileName;
//===================================================================
//--------- check if a data file is opened --------------------------
bool haveOpenedFile();
//=========================================================================
//----------------------- function for node ----------------------
// see value from a input key
void viewNode(RBTree & tree, Cache & cache);
// get data value from data file
int viewValue(int pos);
// add node into tree, if cache filled, update data file
void addNode(RBTree & tree, Cache & cache);
// modify node, if cache filled, update data file
void modifyNode(RBTree & tree, Cache & cache);
// delete node, if cache filled, update data file
void deleteNode(RBTree & tree, Cache & cache);
//==========================================================================
//----------------------- function for file -----------------------
// open data file and initialize tree
void getFile(RBTree & tree, Cache & cache);
// get file name
void getFileName();
// update data file
void updateFile(RBTree & tree, Cache & cache);
void fileModifyNode(int pos, int value);
void fileAddNode(int pos, int key, int value);
//=============================================================================
//----------------------- function for tree ------------------------------
// set tree from input index file
// if the data file has no index file, set tree from the data file
void treeFromFile(RBTree & tree, Cache & cache);
// the data file has no index file
// set the tree from raw data, then set index file
void treeFromData(RBTree & tree, Cache & cache);
// add node from information get from index file
void indexAddNode(RBTree & tree, vector<int>& nodePos, int dataKey, int dataPos, int nodeColor);
// after set tree, set index file for futrue need
void setIndexFile(RBTree & tree);
//==============================================================================
//----------------------- check input ------------------------------------------
bool isNum(string & str);
#endif