-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame.cpp
More file actions
59 lines (54 loc) · 1.02 KB
/
Frame.cpp
File metadata and controls
59 lines (54 loc) · 1.02 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
#include"Formula.h"
#include"Frame.h"
void Frame::AddFormula(Formula* f)
{
if (!f)return;
for (int i = 0; i <= (int)fs.size() - 1; i++) {
if (fs[i] == nullptr) {
fs[i] = f;
return;
}
}
fs.push_back(f);
}
bool Frame::DeleteFormula(char id)
{
int pos = FindFormula(id);
if (pos == -1)return false;
delete fs[pos];
fs[pos] = nullptr;
return true;
}
void Frame::Culc()
{
this->FsInvalid();
for (int i = 0; i <= (int)fs.size() - 1; i++) {
if (this->fs[i] != nullptr) {
this->fs[i]->Culc();
}
}
}
void Frame::FsInvalid()
{
for (int i = 0; i <= (int)fs.size() - 1; i++) {
if (this->fs[i] != nullptr) {
this->fs[i]->IsUpdated = false;
}
}
}
rational Frame::GetValue(char id)
{
int pos = this->FindFormula(id);
if (pos == -1)return DEFAULT_VALUE;
if (this->fs[pos]->IsUpdated == false)this->fs[pos]->Culc();
return this->fs[pos]->value;
}
int Frame::FindFormula(char id)
{
for (int i = 0; i <= (int)fs.size() - 1; i++) {
if (this->fs[i] != nullptr) {
if(fs[i]->id == id)return i;
}
}
return -1;
}