Ch03栈与队列3.pptVIP

  • 7
  • 0
  • 约1.23万字
  • 约 67页
  • 2017-03-04 发布于江苏
  • 举报
第三章 栈与队列 3.1 栈 Stack 栈可定义为只允许在表的末端进行插入和删除的线性表。 允许插入和删除 的一端称为栈顶 top ,另一端称 为栈底 bottom 特点 先进后出 FILO 栈的抽象数据类型 二、顺序栈 栈的其他成员函数的实现 template void SeqStack ::overflowProcess //私有函数:当栈满则执行扩充栈存储空间处理 T *newArray new T[maxSize+stackIncreament]; //创建更大的存储数组 if newArray NULL cerr “存储分配失败!” endl; exit 1 ; for int i 0; i top; i++ newArray[i] elements[i]; maxSize maxSize+stackIncreament; delete []elements; elements newArray; //改变elements指针 ; template void SeqStack ::Push const T x if overflowProcess; //栈满 elements[++top] x; //栈顶指针先加1, 再进栈 ; template bo

文档评论(0)

1亿VIP精品文档

相关文档