friendev EtherDune TCP/IP library
/home/jander/temp/etherdune/List.cpp
Go to the documentation of this file.
1 // EtherDune Linked list class
2 // Author: Javier Peletier <jm@friendev.com>
3 //
4 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
5 //
6 // This source is subject to the GPLv2 license.
7 // Please see the License.txt file for more information.
8 // All other rights reserved.
9 //
10 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
11 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13 // PARTICULAR PURPOSE.
14 
15 #include "List.h"
16 
17 ListItem::ListItem() :nextItem(NULL)
18 {
19 
20 }
21 
22 List::List() : first(NULL)
23 {
24 
25 }
26 
27 void List::add(ListItem* item)
28 {
29  item->nextItem = first;
30  first = item;
31 }
32 
34 {
35  ListItem* last = NULL;
36  for (ListItem* n = first; n != NULL; last = n, n = n->nextItem)
37  {
38  if (n == item)
39  {
40  if (last == NULL)
41  first = n->nextItem;
42  else
43  last->nextItem = n->nextItem;
44 
45  return;
46  }
47  }
48 }
49 
Base list item class.
Definition: List.h:29
List()
Definition: List.cpp:22
ListItem * nextItem
Definition: List.h:39
ListItem()
Definition: List.cpp:17
ListItem * first
Definition: List.h:47
void add(ListItem *item)
Definition: List.cpp:27
void remove(ListItem *item)
Definition: List.cpp:33