listp.h

来自「Data Abstraction & Problem Solving with 」· C头文件 代码 · 共 41 行

H
41
字号
// *********************************************************// Header file ListP.h for the ADT list.// Pointer-based implementation.// *********************************************************#include "ListIndexOutOfRangeException.h"typedef desired-type-of-list-item ListItemType;class List{public:// constructors and destructor:   List();                    // default constructor   List(const List& aList);   // copy constructor   ~List();                   // destructor// list operations:   bool isEmpty() const;   int getLength() const;   void insert(int index, ListItemType newItem)         throw(ListIndexOutOfRangeException);   void remove(int index)         throw(ListIndexOutOfRangeException);   void retrieve(int index, ListItemType& dataItem) const         throw(ListIndexOutOfRangeException);private:   struct ListNode            // a node on the list   {      ListItemType     item;  // a data item on the list      ListNode        *next;  // pointer to next node   };  // end struct   int       size;  // number of items in list   ListNode *head;  // pointer to linked list of items   ListNode *find(int index) const;   // Returns a pointer to the index-th node   // in the linked list.}; // end class// End of header file.

⌨️ 快捷键说明

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