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 |
|
---|
| 12 | namespace ArduinoJson {
|
---|
| 13 | namespace Internals {
|
---|
| 14 |
|
---|
| 15 | // A read-only forward itertor for List<T>
|
---|
| 16 | template <typename T>
|
---|
| 17 | class ListConstIterator {
|
---|
| 18 | public:
|
---|
| 19 | explicit ListConstIterator(const ListNode<T> *node = NULL) : _node(node) {}
|
---|
| 20 |
|
---|
| 21 | const T &operator*() const { return _node->content; }
|
---|
| 22 | const T *operator->() { return &_node->content; }
|
---|
| 23 |
|
---|
| 24 | bool operator==(const ListConstIterator<T> &other) const {
|
---|
| 25 | return _node == other._node;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | bool operator!=(const ListConstIterator<T> &other) const {
|
---|
| 29 | return _node != other._node;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | ListConstIterator<T> &operator++() {
|
---|
| 33 | if (_node) _node = _node->next;
|
---|
| 34 | return *this;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | private:
|
---|
| 38 | const ListNode<T> *_node;
|
---|
| 39 | };
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.