X-Git-Url: https://jfr.im/git/irc/gameservirc.git/blobdiff_plain/0a1518faa49d2d19f189a0abfbf539c14a7c2f64..c7340cbda3026cff96c6250c7d35e51a194658f5:/gameserv/list.h diff --git a/gameserv/list.h b/gameserv/list.h index 8a9287c..384e9ad 100644 --- a/gameserv/list.h +++ b/gameserv/list.h @@ -6,6 +6,7 @@ #include "listnode.h" #include "aClient.h" + template class List { public: @@ -18,6 +19,7 @@ class List { bool remove( T * ); bool isEmpty() const; void print() const; + ListNode < T > *Find( T * ); ListNode < T > *First() { return firstPtr; }; ListNode < T > *Last() { return lastPtr; }; private: @@ -142,6 +144,21 @@ ListNode *List::getNewNode( const T &value) return ptr; } +template +ListNode *List::Find( T *value ) +{ + if (isEmpty()) {return NULL;} + + ListNode *currentPtr; + currentPtr = firstPtr; + while (currentPtr) + { + if (currentPtr->getData() == value) + return currentPtr; + currentPtr = currentPtr->Next(); + } + return NULL; +} template void List::print() const @@ -156,11 +173,11 @@ void List::print() const currentPtr = firstPtr; while (currentPtr) { - cout << "aClient: " << currentPtr->getData() << flush; + cout << "aClient: " << *currentPtr->getData() << flush; if (currentPtr->getData()->stats) - cout << " Player Name: " << ¤tPtr->getData()->stats->name - << " Password: " << ¤tPtr->getData()->stats->password << flush; + cout << " Player Name: " << currentPtr->getData()->stats->name + << " Password: " << currentPtr->getData()->stats->password << flush; cout << endl; currentPtr = currentPtr->next; }