#include "listnode.h"
#include "aClient.h"
#include "extern.h"
+#include "options.h"
using std::cout;
using std::endl;
+using std::flush;
template <class T>
class List {
void insertAtBack( T *&);
bool removeFromFront( T & );
bool removeFromBack( T & );
- bool remove( T * );
+ bool del( T *);
+ ListNode < T > *remove( T * );
bool isEmpty() const;
void print() const;
ListNode < T > *Find( T * );
cout << endl;
currentPtr = currentPtr->next;
}
-
}
#endif
template <class T>
-bool List<T>::remove(T *remPtr)
+bool List<T>::del(T *remPtr)
+{
+ ListNode<T> *removed = remove( remPtr );
+ if (removed != NULL)
+ {
+ delete removed;
+ return true;
+ }
+ return false;
+}
+
+template <class T>
+ListNode<T> *List<T>::remove(T *remPtr)
{
ListNode<T> *newPtr = firstPtr;
T *testPtr;
log("One Element. Deleting it");
#endif
firstPtr = lastPtr = NULL;
- delete newPtr;
- return true;
+ return newPtr;
}
else if (newPtr != lastPtr && newPtr != firstPtr)
{
#endif
newPtr->prev->next = newPtr->next;
newPtr->next->prev = newPtr->prev;
- delete newPtr;
- return true;
+ return newPtr;
}
else if (newPtr == lastPtr)
{
#endif
lastPtr = newPtr->prev;
lastPtr->next = 0;
- delete newPtr;
- return true;
+ return newPtr;
}
else if (newPtr == firstPtr)
{
#endif
firstPtr = newPtr->next;
firstPtr->prev = 0;
- delete newPtr;
- return true;
+ return newPtr;
}
}
newPtr = newPtr->next;
}
- return false;
+ return NULL;
}
#endif