};
template class Type
const int StackType::DefaultSize = 10;
template class Type
StackType::Stack(int pMaxSize) {
MaxSize = pMaxSize;
stack = new Type[MaxSize];
top = -1;
}
template class Type
StackType::Stack(Type pArray[], int pLen, int pMaxSize) {
stack = new Type[pMaxSize];
for ( int i = 0; ipLen; i++ )
{
stack[i] = pArray[i];
}
top = pLen - 1;
MaxSize = pMaxSize;
}
template class Type
inline bool StackType::IsFull() {
if (top == MaxSize - 1) return true;
else return false;
}
template class Type
inline bool StackType::IsEmpty() {
if (top == -1) return true;
else return false;
}
template class Type
void StackType::Add(const TypepX) {
if (IsFull())
{
StackFull();
stack[++top] = pX;
}
else stack[++top] = pX;
}
template class Type
Type * StackType::Delete(TypepX) {
if (IsEmpty())
{
StackEmpty();
return 0;
}
pX = stack[top--];
return pX;
}
template class Type
void StackType::StackEmpty() {
cout"栈已空,不能进行弹出操作!"endl;
}
template class Type
void StackType::StackFull() {
Type * nStack = new Type[MaxSize * 2];
for ( int i = 0; i = top; i++ )
{
nStack[i] = stack[i];
}
MaxSize = MaxSize * 2;
delete [] stack;
stack = nStack;
cout"栈已满,栈的自动容量自动扩充为原来的两倍 ("MaxSize")"endl;
}
template class Type
ostreamoperator(ostreampOutput, const StackTypepS) {
if (pS.top == -1)
{
pOutput"空栈"endl;
return pOutput;
}
for ( int i = 0; i = pS.top; i++ )
{
pOutputpS.stack[i]" ";
}
return pOutput;
}
template class Type
void StackType::Empty() {
top = -1;
}
template class Type
int StackType::GetSize() {
return top + 1;
}
#endif
关于c语言数据结构队列主函数和数据结构队列代码c语言的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- 桌面俯视直播工具怎么用,俯视桌面图
- wordpress优化代码,优化wordpress打开速度
- 动作识别游戏设备,动作识别游戏设备
- excel两个文档怎么合并,excel怎么把两个文档合成一个
- Go语言构建工具 golang构建工具
- mongodb启动后,mongodb报错
- 动作游戏大门,大班动作游戏
- js将字符串以逗号分隔符,js以逗号分隔转换为数组
- go语言生成二维切片 go 二维切片初始化