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

Embed: (wiki syntax)

« Back to documentation index

LL< retT > Class Template Reference

LL< retT > Class Template Reference

Example using the LL Class. More...

#include <LL.h>

Public Member Functions

 LL ()
 Create the LL object.
 ~LL ()
 Deconstructor for the LL object Removes any members.
retT * push (void *data)
 Add a member to the begining of the list.
retT * append (void *data)
 Add a member to some position in the list.
retT * remove (uint32_t loc)
 Remove a member from the list.
retT * pop (uint32_t loc)
 Get access to a member from the list.
uint32_t length (void)
 Get the length of the list.

Detailed Description

template<class retT>
class LL< retT >

Example using the LL Class.

  #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");
  }

API abstraction for a Linked List

Definition at line 72 of file LL.h.


Constructor & Destructor Documentation

LL (  )

Create the LL object.

Definition at line 26 of file LL.cpp.

~LL (  )

Deconstructor for the LL object Removes any members.

Definition at line 35 of file LL.cpp.


Member Function Documentation

retT * append ( void *  data )

Add a member to some position in the list.

Parameters:
data- Some data type that is added to the list
loc- Place in the list to put the data
Returns:
The member that was just inserted (NULL if empty) Add a member to the end of the list
Parameters:
data- Some data type that is added to the list
Returns:
The member that was just inserted (NULL if empty)

Definition at line 82 of file LL.cpp.

uint32_t length ( void   )

Get the length of the list.

Returns:
The number of members in the list

Definition at line 159 of file LL.cpp.

retT * pop ( uint32_t  loc )

Get access to a member from the list.

Parameters:
loc- The location of the member to access
Returns:
The member that was just requested (NULL if empty or out of bounds)

Definition at line 141 of file LL.cpp.

retT * push ( void *  data )

Add a member to the begining of the list.

Parameters:
data- Some data type that is added to the list
Returns:
The member that was just inserted (NULL if empty)

Definition at line 44 of file LL.cpp.

retT * remove ( uint32_t  loc )

Remove a member from the list.

Parameters:
loc- The location of the member to remove
Returns:
The head of the list

Definition at line 111 of file LL.cpp.