Rev | Line | |
---|
[209] | 1 | // Copyright Benoit Blanchon 2014-2016
|
---|
| 2 | // MIT License
|
---|
| 3 | //
|
---|
| 4 | // Arduino JSON library
|
---|
| 5 | // https://github.com/bblanchon/ArduinoJson
|
---|
| 6 | // If you like this project, please add a star!
|
---|
| 7 |
|
---|
| 8 | #pragma once
|
---|
| 9 |
|
---|
| 10 | #include "ListNode.hpp"
|
---|
| 11 | #include "ListConstIterator.hpp"
|
---|
| 12 |
|
---|
| 13 | namespace ArduinoJson {
|
---|
| 14 | namespace Internals {
|
---|
| 15 |
|
---|
| 16 | // A read-write forward iterator for List<T>
|
---|
| 17 | template <typename T>
|
---|
| 18 | class ListIterator {
|
---|
| 19 | public:
|
---|
| 20 | explicit ListIterator(ListNode<T> *node = NULL) : _node(node) {}
|
---|
| 21 |
|
---|
| 22 | T &operator*() const { return _node->content; }
|
---|
| 23 | T *operator->() { return &_node->content; }
|
---|
| 24 |
|
---|
| 25 | bool operator==(const ListIterator<T> &other) const {
|
---|
| 26 | return _node == other._node;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | bool operator!=(const ListIterator<T> &other) const {
|
---|
| 30 | return _node != other._node;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | ListIterator<T> &operator++() {
|
---|
| 34 | if (_node) _node = _node->next;
|
---|
| 35 | return *this;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | operator ListConstIterator<T>() const { return ListConstIterator<T>(_node); }
|
---|
| 39 |
|
---|
| 40 | private:
|
---|
| 41 | ListNode<T> *_node;
|
---|
| 42 | };
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.