📄 c08p409b.txt
字号:
// *********************************************************// Header file List.h for the ADT list.// Uses ListNode and BasicADT.// *********************************************************#include "ListNode.h" // as specified in previous section, // also specifies ListItemType#include "ListException.h" #include "ListIndexOutOfRangeException.h"#include "BasicADT.h"class List : public BasicADT{public:// constructors and destructor: List(); List(const List& aList); virtual ~List();// list operations: virtual bool isEmpty() const; virtual int getLength() const; virtual void insert(int index, ListItemType newItem) throw(ListIndexOutOfRangeException, ListException); virtual void remove(int index) throw(ListIndexOutOfRangeException); virtual void retrieve(int index, ListItemType& dataItem) const throw(ListIndexOutOfRangeException);protected: void setSize(int newSize); // sets size ListNode *getHead() const; // returns head pointer void setHead(ListNode *newHead); // sets head pointer // the next two functions return the list item or // next pointer of a node in the linked list ListItemType getNodeItem(ListNode *ptr) const; ListNode *getNextNode(ListNode *ptr) const;private: int size; // number of items in the list ListNode *head; // pointer to the linked list ListNode *find(int index) const;}; // end class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -