📄 table.cpp
字号:
#include <windows.h>
#include <stdio.h>
#include "Table.h"
GRID::GRID()
{
StackTopSign = END_SIGN;
InputSign = END_SIGN;
}
void GRID::operator=(const GRID& other)
{
StackTopSign = other.StackTopSign;
InputSign = other.InputSign;
SelectableRule = other.SelectableRule;
}
TABLE::TABLE() : StackTopSignSet(),InputSignSet()
{
nGrids = 0;
Grid = 0;
m_bDetered = true;
LeftRecursive = false;
}
TABLE::TABLE(const TABLE& other) : StackTopSignSet(),InputSignSet()
{
nGrids = 0;
Grid = 0;
*this = other;
}
TABLE::~TABLE()
{
Reset();
}
bool TABLE::IsDeterminate()
{
return m_bDetered;
}
void TABLE::operator=(const TABLE& other)
{
Reset();
StackTopSignSet = other.StackTopSignSet;
InputSignSet = other.InputSignSet;
m_bDetered = other.m_bDetered;
StartSign = other.StartSign;
LeftRecursive = other.LeftRecursive;
nGrids = other.nGrids;
Grid = new GRID[nGrids];
CopyMemory(Grid,other.Grid,sizeof(GRID) * nGrids);
}
void TABLE::Reset()
{
StackTopSignSet.Reset();
InputSignSet.Reset();
if (Grid) delete []Grid;
nGrids = 0;
Grid = 0;
m_bDetered = true;
LeftRecursive = false;
}
int TABLE::AddGrid(SIGN StackTop,SIGN Input,RULE Rule)
{
int i;
GRID* pTemp;
// 检查是否有在一个格子填写多个规则的情形
for(i = 0; i < nGrids; i++)
if (Grid[i].StackTopSign == StackTop && Grid[i].InputSign == Input)
{
m_bDetered = false;
break;
}
pTemp = Grid;
Grid = new GRID[nGrids + 1];
CopyMemory(Grid,pTemp,sizeof(GRID) * nGrids);
Grid[nGrids].StackTopSign = StackTop;
Grid[nGrids].InputSign = Input;
Grid[nGrids].SelectableRule = Rule;
nGrids = nGrids + 1;
delete []pTemp;
return nGrids;
}
GRID TABLE::operator[](int NO)
{
GRID grid;
if (NO >= 0 && NO < nGrids)
grid = Grid[NO];
return grid;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -