stack.h

来自「数据结构与算法分析(C++)(版第二版)源码」· C头文件 代码 · 共 20 行

H
20
字号
// Stack abtract class
template <class Elem> class Stack {
public:
  // Reinitialize the stack.  The user is responsible for
  // reclaiming the storage used by the stack elements.
  virtual void clear() = 0;
  // Push an element onto the top of the stack.  Return
  // true if successful, false if not (if stack is full).
  virtual bool push(const Elem&) = 0;
  // Remove the element at the top of the stack. Return
  // true if succesful, false if stack is empty.
  // The element removed is returned in the first parameter.
  virtual bool pop(Elem&) = 0; // Pop Elem from top of stack
  // Return in first parameter a copy of the top element.
  // Return true if succesful, false if stack is empty.
  virtual bool topValue(Elem&) const = 0;
  // Return the number of elements in the stack.
  virtual int length() const = 0;
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?