Class to manage a linked list. Utility that can be built on or used alone

Dependents:   Waldo_Embed_V2 elevator_with_queue RaheeNew DS1820 ... more

Good information on linked list basics here.

Information

Dependencies not included with library:

#include "mbed.h"
#include "LL.h"
  
LL<node>list;
  
int main()
{
    node *tmp;
      
    list.push((char *)"Two\n");
    list.append((char *)"Three\n");
    list.append((char *)"Four\n");
    list.push((char*)"One\n");
    list.append((char*)"Five\n");
      
    for(int i=1; i<=list.length(); i++)
    {
        tmp = list.pop(i);
        printf("%s", (char *)tmp->data );
    }
      
    error("done\n");
}
Revision:
5:28e11c75b433
Parent:
4:59b2aa82b517
Child:
6:e3ab7684c395
--- a/LinkedList.cpp	Wed Apr 10 06:17:21 2013 +0000
+++ b/LinkedList.cpp	Mon May 13 04:38:05 2013 +0000
@@ -37,10 +37,7 @@
 LinkedList<retT>::~LinkedList()
 {
     // free any memory that is on the heap
-    while(0 != length())
-    {
-        LinkedList::remove(1);
-    }
+    while(remove(1) != NULL);
 
     return;
 }
@@ -133,7 +130,7 @@
     retT *current = _head;
     retT *prev = 0;
     // make sure we have an item to remove
-    if ((loc < length()) && (loc > 0))
+    if ((loc <= length()) && (loc > 0))
     {
         // move to the item we want to delete
         if (1 == loc)