-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemory.h
More file actions
43 lines (39 loc) · 1.05 KB
/
Memory.h
File metadata and controls
43 lines (39 loc) · 1.05 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
#pragma once
#include "Hash.h"
class MemoryNode
{
private:
int left;
int right;
public:
MemoryNode() { this->left = 0, this->right = 0; }
int getLeft(void) { return this->left; }
int getRight(void) { return this->right; }
void setLeft(int val) { this->left = val; }
void setRight(int val) { this->right = val; }
};
class MemoryTable
{
private:
MemoryNode* memorytable;
HashTable& hashtable;
int free_list;
int node_root;
void setMemoryNode(int ind);
std::string echo(int ind);
void dealloc(int ind);
public:
MemoryTable(HashTable& hashtable) : hashtable(hashtable) { memorytable = new MemoryNode[SIZE_OF_MEMORY_TABLE], free_list = 1, node_root = 1; }
~MemoryTable() { delete[] memorytable; }
void initmemorytable(void);
MemoryNode& operator[](int ind) { return memorytable[ind]; }
void setNode_root(int ind);
int alloc(void);
void initFree_list(void) { free_list = 1; }
int getFree_list(void) { return free_list; }
int getNode_root(void) { return node_root; }
void printTable(void);
std::string echo(void);
void print(void);
void dealloc(void);
};