]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/list.h
updated the Change Log
[irc/gameservirc.git] / gameserv / list.h
index d19e5564614454726289ca9b41a7bd936816c83b..4053e4ab56f9248e9c324cfdbbf5e800d3ff6391 100644 (file)
@@ -17,8 +17,9 @@ class List {
     public:
        List();         //constructor
        ~List();        //deconstructor
-       void insertAtFront( const T & );
-       void insertAtBack( T *&);
+       T *insertAtFront( const T & );
+       T *insertAtBack( T *&);
+       ListNode<T> *insertAtBack_RLN( T *&);
        bool removeFromFront( T & );
        bool removeFromBack( T & );
        bool del( T *);
@@ -67,7 +68,7 @@ List<T>::~List()
 }
 
 template<class T>
-void List<T>::insertAtFront( const T &value )
+T *List<T>::insertAtFront( const T &value )
 {
     ListNode<T> *newPtr = getNewNode ( value );
 
@@ -80,10 +81,11 @@ void List<T>::insertAtFront( const T &value )
        firstPtr->prev = newPtr;
        firstPtr = newPtr;
     }
+    return firstPtr->getData();
 }
 
 template<class T>
-void List<T>::insertAtBack(T *&value )
+T *List<T>::insertAtBack(T *&value )
 {
     ListNode<T> *newPtr = getNewNode(*value);
 
@@ -97,6 +99,25 @@ void List<T>::insertAtBack(T *&value )
        lastPtr->next = newPtr;
        lastPtr = newPtr;
     }
+    return lastPtr->getData();
+}
+
+template<class T>
+ListNode<T> *List<T>::insertAtBack_RLN(T *&value )
+{
+    ListNode<T> *newPtr = getNewNode(*value);
+
+    if (isEmpty())
+    {
+       firstPtr = lastPtr = newPtr;
+    }
+    else
+    {
+       newPtr->prev = lastPtr;
+       lastPtr->next = newPtr;
+       lastPtr = newPtr;
+    }
+    return lastPtr;
 }
 
 
@@ -163,6 +184,7 @@ ListNode<T> *List<T>::Find( T *value )
     currentPtr = firstPtr;
     while (currentPtr)
     {
+       cout << currentPtr->getData() << endl << value << endl;
        if (currentPtr->getData() == value)
            return currentPtr;
        currentPtr = currentPtr->Next();