alist.h

来自「经典c++程序的实现」· C头文件 代码 · 共 25 行

H
25
字号
class list {              // Array-based list class
private:
  int msize;                  // Maximum size of list
  int numinlist;              // Actual number of ELEMs in list
  int curr;                   // Position of "current" ELEM
  ELEM* listarray;            // Array holding list ELEMs
public:
  list(const int =LIST_SIZE); // Constructor
  ~list();                    // Destructor
  void clear();               // Remove all ELEMs from list
  void insert(const ELEM&);   // Insert ELEM at current position
  void append(const ELEM&);   // Insert ELEM at tail of list
  ELEM remove();              // Remove and return current ELEM
  void setFirst();            // Set curr to first position
  void prev();                // Move curr to previous position
  void next();                // Move curr to next position
  int  length() const;        // Return current length of list
  void setPos(const int);     // Set curr to specified position
  void setValue(const ELEM&); // Set current ELEM's value
  ELEM currValue() const;     // Return current ELEM's value
  bool isEmpty() const;       // Return TRUE if list is empty
  bool isInList() const;      // TRUE if curr is within list
  bool find(const ELEM&);     // Find value (from current position)
};

⌨️ 快捷键说明

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