#include "listnode.h"
#include "aClient.h"
+
template <class T>
class List {
public:
bool remove( T * );
bool isEmpty() const;
void print() const;
+ ListNode < T > *Find( T * );
ListNode < T > *First() { return firstPtr; };
ListNode < T > *Last() { return lastPtr; };
private:
{
tempPtr = currentPtr;
currentPtr = currentPtr->Next();
-// if (!tempPtr->getData()->stats || tempPtr->getData()->stats->started == 0)
cout << "Deleting Memory address: " << tempPtr->getData() << endl << flush;
delete tempPtr;
-// else
-// tempPtr->getData()->stats->started = 0;
}
cout << "All Nodes destroyed" << endl;
}
return ptr;
}
+template<class T>
+ListNode<T> *List<T>::Find( T *value )
+{
+ if (isEmpty()) {return NULL;}
+
+ ListNode<T> *currentPtr;
+ currentPtr = firstPtr;
+ while (currentPtr)
+ {
+ if (currentPtr->getData() == value)
+ return currentPtr;
+ currentPtr = currentPtr->Next();
+ }
+ return NULL;
+}
template <class T>
void List<T>::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;
}