Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SimpleGUI by
Diff: Core/LinkedList.h
- Revision:
- 15:e69fd74d42e4
- Parent:
- 12:63db16fea709
- Child:
- 18:d849f3ada858
diff -r e6515b19f5a0 -r e69fd74d42e4 Core/LinkedList.h
--- a/Core/LinkedList.h Sat May 21 16:36:02 2016 +0000
+++ b/Core/LinkedList.h Sat May 21 18:02:20 2016 +0000
@@ -22,7 +22,7 @@
public:
- LinkedList() : _first(NULL), _next(NULL), _current(NULL) {}
+ LinkedList() : _first(NULL), _next(NULL), _current(NULL), _size(0) {}
~LinkedList() {}
@@ -43,6 +43,7 @@
p->next = d;
}
+ _size++;
}
void appendOnce(T* data) {
@@ -50,6 +51,7 @@
if(_first == NULL) {
_first = new LinkedListNode<T>(data);
+ _size++;
} else {
@@ -66,6 +68,7 @@
}
p->next = d;
+ _size++;
}
}
void remove(T* data) {
@@ -80,12 +83,14 @@
if(_first->data == data) {
_first = _first->next;
delete next;
+ _size--;
} else {
next = _first->next;
while(next) {
if(next->data == data) {
prev->next = next->next;
delete next;
+ _size--;
return;
}
prev = next;
@@ -103,6 +108,7 @@
here = next;
}
_first = NULL;
+ _size = 0;
}
void reset() {
@@ -130,6 +136,10 @@
}
return false;
}
+
+ int size() {
+ return _size;
+ }
protected:
@@ -137,6 +147,7 @@
LinkedListNode<T>* _first;
LinkedListNode<T>* _next;
LinkedListNode<T>* _current;
+ int _size;
};
