From fc9ad20e7a05e6fbcaca2acf5215f166ad1790d5 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 19 Jan 2015 03:52:06 +0000 Subject: [PATCH] touched up code a little bit --- qse/include/qse/cmn/HashList.hpp | 10 ++++---- qse/include/qse/cmn/LinkedList.hpp | 39 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/qse/include/qse/cmn/HashList.hpp b/qse/include/qse/cmn/HashList.hpp index c9a990cd..ba010302 100644 --- a/qse/include/qse/cmn/HashList.hpp +++ b/qse/include/qse/cmn/HashList.hpp @@ -24,8 +24,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _QSE_CMN_HASHLIST_CLASS_ -#define _QSE_CMN_HASHLIST_CLASS_ +#ifndef _QSE_CMN_HASHLIST_HPP_ +#define _QSE_CMN_HASHLIST_HPP_ #include #include @@ -152,7 +152,7 @@ public: do { - copy_datum (np, this->node_capacity, this->nodes, this->datum_list); + this->copy_datum (np, this->node_capacity, this->nodes, this->datum_list); if (np == list.nodes[tail]) break; np = np->getNextNode (); } @@ -364,12 +364,12 @@ public: Node* getHeadNode () const { - return datum_list->getHeadNode(); + return this->datum_list->getHeadNode(); } Node* getTaileNode () const { - return datum_list->getTailNode(); + return this->datum_list->getTailNode(); } typedef int (SelfType::*TraverseCallback) (Node* start, Node* cur); diff --git a/qse/include/qse/cmn/LinkedList.hpp b/qse/include/qse/cmn/LinkedList.hpp index 038ab321..2895ffbc 100644 --- a/qse/include/qse/cmn/LinkedList.hpp +++ b/qse/include/qse/cmn/LinkedList.hpp @@ -43,50 +43,51 @@ class LinkedListNode: protected Mpoolable { public: friend class LinkedList; - typedef LinkedListNode Node; + typedef LinkedListNode SelfType; T value; // you can use this variable or accessor functions below protected: - Node* next; - Node* prev; + SelfType* next; + SelfType* prev; public: T& getValue () { return this->value; } const T& getValue () const { return this->value; } void setValue (const T& v) { this->value = v; } - Node* getNext () { return this->next; } - const Node* getNext () const { return this->next; } - Node* getNextNode () { return this->next; } - const Node* getNextNode () const { return this->next; } + SelfType* getNext () { return this->next; } + const SelfType* getNext () const { return this->next; } + SelfType* getNextNode () { return this->next; } + const SelfType* getNextNode () const { return this->next; } - Node* getPrev () { return this->prev; } - const Node* getPrev () const { return this->prev; } - Node* getPrevNode () { return this->prev; } - const Node* getPrevNode () const { return this->prev; } + SelfType* getPrev () { return this->prev; } + const SelfType* getPrev () const { return this->prev; } + SelfType* getPrevNode () { return this->prev; } + const SelfType* getPrevNode () const { return this->prev; } protected: LinkedListNode (): prev(QSE_NULL), next(QSE_NULL) {} LinkedListNode (const T& v): value(v), prev(QSE_NULL), next(QSE_NULL) {} - void setNext (const Node* node) + void setNext (const SelfType* node) { this->next = node; } - void setPrev (const Node* node) + void setPrev (const SelfType* node) { this->prev = node; } }; /// -/// The LinkedList class provides a template for a doubly-linked list. +/// The LinkedList class provides a template for a doubly-linked list. /// template class LinkedList { public: + typedef LinkedList SelfType; typedef LinkedListNode Node; enum @@ -106,7 +107,7 @@ public: this->tail_node = QSE_NULL; } - LinkedList (const LinkedList& ll): mp (ll.mp.getDatumSize(), ll.mp.getBlockSize()) + LinkedList (const SelfType& ll): mp (ll.mp.getDatumSize(), ll.mp.getBlockSize()) { this->node_count = 0; this->head_node = QSE_NULL; @@ -115,7 +116,7 @@ public: this->append (p->value); } - LinkedList& operator= (const LinkedList& ll) + SelfType& operator= (const SelfType& ll) { this->clear (); for (Node* p = ll.head_node; p != QSE_NULL; p = p->next) @@ -222,7 +223,7 @@ public: return this->insertValue ((Node*)QSE_NULL, value); } - void prependAll (const LinkedList& list) + void prependAll (const SelfType& list) { Node* n = list.tail_node; @@ -246,7 +247,7 @@ public: } } - void appendAll (const LinkedList& list) + void appendAll (const SelfType& list) { Node* n = list.head_node; @@ -523,7 +524,7 @@ public: this->mp.dispose (); } - typedef int (LinkedList::*TraverseCallback) (Node* start, Node* cur); + typedef int (SelfType::*TraverseCallback) (Node* start, Node* cur); void traverse (TraverseCallback callback, Node* start) {