0%
一、順序表
二、單鏈表(Single Linked List)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| template<class T> struct LinkNode { T data; LinkNode<T> *next; LinkNode (LinkNode<T> *ptr = NULL){next = ptr;} LinkNode (const T &item, LinkNode<T> *ptr = NULL) { next = ptr; data = item; } };
template<class T> class LinkList { public: LinkList (){head = new LinkNode<T>;} LinkList (const T &item){head = new LinkNode<T>(item);} LinkList (LinkList<T> &List); ~LinkList (){Clear ();} LinkList<T>& operator=(LinkList<T> &List); LinkNode<T>* Locate (int pos); bool Insert (T &item, int pos); bool Remove (int pos, T &item); void Clear (); int Length () const; void Print () const; LinkNode<T>* GetHead () const; void SetHead (LinkNode<T> *p); LinkNode<T>* Find (T &item); bool GetData (int pos, T &item); bool SetData (int pos, T &item); bool IsEmpty () const; void Sort (); void Reverse (); private: LinkNode<T> *head; };
|
三、靜態表
二、棧(Stack)
三、隊列(Queue)
四、串(String)
五、陣列(Array)
六、廣義表(Generalize List)