CollectionIterator: rename next() to move()

This commit is contained in:
Benoit Blanchon
2025-10-20 12:08:06 +02:00
parent af36add5d8
commit a51865ca42
8 changed files with 16 additions and 16 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ inline VariantImpl::iterator VariantImpl::at(size_t index) const {
auto it = createIterator();
while (!it.done() && index) {
it.next(resources_);
it.move(resources_);
--index;
}
return it;
@@ -37,7 +37,7 @@ inline VariantData* VariantImpl::addNewElement(VariantData* data,
inline VariantData* VariantImpl::getOrAddElement(size_t index) {
auto it = createIterator();
while (!it.done() && index > 0) {
it.next(resources_);
it.move(resources_);
index--;
}
if (it.done())
+2 -2
View File
@@ -50,7 +50,7 @@ class JsonArrayIterator {
}
JsonArrayIterator& operator++() {
iterator_.next(resources_);
iterator_.move(resources_);
return *this;
}
@@ -84,7 +84,7 @@ class JsonArrayConstIterator {
}
JsonArrayConstIterator& operator++() {
iterator_.next(resources_);
iterator_.move(resources_);
return *this;
}
@@ -8,7 +8,7 @@
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
inline void CollectionIterator::next(const ResourceManager* resources) {
inline void CollectionIterator::move(const ResourceManager* resources) {
ARDUINOJSON_ASSERT(slot_);
auto nextId = slot_->next;
slot_ = resources->getVariant(nextId);
@@ -136,7 +136,7 @@ inline size_t VariantImpl::nesting() const {
if (!data_ || !data_->isCollection())
return 0;
size_t maxChildNesting = 0;
for (auto it = createIterator(); !it.done(); it.next(resources_)) {
for (auto it = createIterator(); !it.done(); it.move(resources_)) {
size_t childNesting = VariantImpl(it.data(), resources_).nesting();
if (childNesting > maxChildNesting)
maxChildNesting = childNesting;
@@ -20,7 +20,7 @@ class CollectionIterator {
public:
CollectionIterator() : slot_(nullptr), currentId_(NULL_SLOT) {}
void next(const ResourceManager* resources);
void move(const ResourceManager* resources);
bool done() const {
return slot_ == nullptr;
@@ -34,8 +34,8 @@ class JsonObjectIterator {
}
JsonObjectIterator& operator++() {
iterator_.next(resources_); // key
iterator_.next(resources_); // value
iterator_.move(resources_); // key
iterator_.move(resources_); // value
return *this;
}
@@ -70,8 +70,8 @@ class JsonObjectConstIterator {
}
JsonObjectConstIterator& operator++() {
iterator_.next(resources_); // key
iterator_.next(resources_); // value
iterator_.move(resources_); // key
iterator_.move(resources_); // value
return *this;
}
+2 -2
View File
@@ -19,7 +19,7 @@ class JsonPair {
detail::ResourceManager* resources) {
if (!iterator.done()) {
key_ = iterator->asString();
iterator.next(resources);
iterator.move(resources);
value_ = JsonVariant(iterator.data(), resources);
}
}
@@ -47,7 +47,7 @@ class JsonPairConst {
detail::ResourceManager* resources) {
if (!iterator.done()) {
key_ = iterator->asString();
iterator.next(resources);
iterator.move(resources);
value_ = JsonVariantConst(iterator.data(), resources);
}
}
+2 -2
View File
@@ -16,7 +16,7 @@ inline VariantData* VariantImpl::getMember(TAdaptedString key,
auto it = findKey(key, data, resources);
if (it.done())
return nullptr;
it.next(resources);
it.move(resources);
return it.data();
}
@@ -45,7 +45,7 @@ inline VariantImpl::iterator VariantImpl::findKey(TAdaptedString key,
return iterator();
bool isKey = true;
for (auto it = createIterator(data, resources); !it.done();
it.next(resources)) {
it.move(resources)) {
if (isKey && stringEquals(key, adaptString(it->asString())))
return it;
isKey = !isKey;
+1 -1
View File
@@ -543,7 +543,7 @@ class VariantImpl {
size_t n = 0;
for (auto it = createIterator(data, resources); !it.done();
it.next(resources))
it.move(resources))
n++;
if (data->type == VariantType::Object) {