c08p418b.txt

来自「Data Abstraction & Problem Solving with 」· 文本 代码 · 共 39 行

TXT
39
字号
// *********************************************************// Header file ListT.h for the ADT list.// Pointer-based implementation -- TEMPLATE VERSION// *********************************************************#include "ListNodeT.h"#include "ListException.h"#include "ListIndexOutOfRangeException.h"template <class T> class List{public:// constructors and destructor:   List();   List(const List<T> & aList);   virtual ~List();   // List operations:   virtual bool isEmpty() const;   virtual int  getLength() const;   virtual void insert(int index, T newItem)          throw(ListIndexOutOfRangeException, ListException);   virtual void remove(int index)         throw(ListIndexOutOfRangeException);   virtual void retrieve(int index, T & dataItem) const          throw(ListIndexOutOfRangeException);protected:   void setSize(int newSize);   ListNode<T> *getHead() const;   void setHead(ListNode<T> *newHead);   T getNodeItem(ListNode<T> *ptr) const;   ListNode<T> *getNextNode(ListNode<T> *ptr) const;private:   int          size;   ListNode<T> *head;   ListNode<T> *find(int position) const;};  // end class#include "ListT.cpp"

⌨️ 快捷键说明

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