forked from haguvenir/Turkish_TTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuleStack.cpp
More file actions
54 lines (48 loc) · 791 Bytes
/
RuleStack.cpp
File metadata and controls
54 lines (48 loc) · 791 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
47
48
49
50
51
52
53
54
#include "TextStruct.h"
RuleStack::RuleStack(int size, int ruleNo)
{
size = size > 0 ? size : 10;
top = -1;
ruleno = ruleNo;
stackPtr = new int[size];
}
RuleStack::~RuleStack()
{
delete [] stackPtr;
}
void RuleStack::MakeEmpty()
{
top = -1;
}
void RuleStack::Push(int data)
{
if(isFull())
Resize(size+10);
stackPtr[++top] = data;
}
int RuleStack::Pop()
{
if(!isEmpty())
return stackPtr[top--];
return -1;
}
const int RuleStack::TopE()
{
if(!isEmpty())
return stackPtr[top];
return -1;
}
void RuleStack::Resize(int nsize)
{
if(nsize < size) return;
int * newarray = new int[nsize];
for(int i=0; i<=top; i++)
newarray[i] = stackPtr[i];
delete [] stackPtr;
stackPtr = newarray;
}
void RuleStack::Display()
{
for(int i=top; i>=0; i--)
cout<<stackPtr[i]<<endl;
}