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:
- 18:d849f3ada858
- Parent:
- 15:e69fd74d42e4
diff -r 5184762fda6c -r d849f3ada858 Core/LinkedList.h
--- a/Core/LinkedList.h Sun May 22 16:35:23 2016 +0000
+++ b/Core/LinkedList.h Sat May 28 14:50:14 2016 +0000
@@ -17,6 +17,30 @@
};
template<class T>
+class LinkedListIterator {
+ public:
+ LinkedListIterator(LinkedListNode<T> *first) {
+ _current = first;
+ }
+
+ ~LinkedListIterator() {}
+
+ T* next() {
+
+ LinkedListNode<T>* p = _current;
+ if(p != NULL) {
+ _current = _current->next;
+ return p->data;
+ }
+
+ return NULL;
+ }
+
+private:
+ LinkedListNode<T>* _current;
+};
+
+template<class T>
class LinkedList
{
@@ -24,7 +48,11 @@
LinkedList() : _first(NULL), _next(NULL), _current(NULL), _size(0) {}
~LinkedList() {}
-
+
+ LinkedListIterator<T> getIterator() {
+ LinkedListIterator<T> iterator(_first);
+ return iterator;
+ }
void append(T* data) {
