【3-1】Chapte3-栈及其应用.pptVIP

  • 5
  • 0
  • 约1.26万字
  • 约 56页
  • 2017-11-19 发布于北京
  • 举报
【3-1】Chapte3-栈及其应用.ppt

数据结构 中国地质大学信息工程学院 2012年秋 第三章 栈和队列 目 录 栈 顺序栈和链式栈 栈的应用 栈与递归 队列 优先队列 顺序栈的类定义(续) bool IsEmpty() const { return top == -1; } //栈空 bool IsFull() const { return top == maxSize-1; } //栈满 int getSize() const { return top+1; } //栈中元素个数 void MakeEmpty() { top = -1; } //清空栈 friend ostream operator (ostream out, SeqStackT s) }; 顺序栈的构造函数 template class T SeqStackT::SeqStack(int sz) { top = -1; maxSize = sz; elements = new T[maxSize]; assert(elements); } 顺序栈的溢出处理 const int stackIncreament = 20; //栈溢出时空间的增量 template class T void SeqStackT::overflowProcess() { //私有函数:当栈满则执行扩

文档评论(0)

1亿VIP精品文档

相关文档