mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-30 02:37:35 +02:00
CollectionIterator: remove data()
This commit is contained in:
@ -40,7 +40,7 @@ inline VariantData* VariantImpl::getOrAddElement(size_t index) {
|
|||||||
}
|
}
|
||||||
if (it.done())
|
if (it.done())
|
||||||
index++;
|
index++;
|
||||||
VariantData* element = it.data();
|
VariantData* element = it->data();
|
||||||
while (index > 0) {
|
while (index > 0) {
|
||||||
element = addElement();
|
element = addElement();
|
||||||
if (!element)
|
if (!element)
|
||||||
@ -51,7 +51,7 @@ inline VariantData* VariantImpl::getOrAddElement(size_t index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline VariantData* VariantImpl::getElement(size_t index) const {
|
inline VariantData* VariantImpl::getElement(size_t index) const {
|
||||||
return at(index).data();
|
return at(index)->data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VariantImpl::removeElement(iterator it) {
|
inline void VariantImpl::removeElement(iterator it) {
|
||||||
|
@ -65,7 +65,7 @@ inline void VariantImpl::removeOne(iterator it) {
|
|||||||
if (it.done())
|
if (it.done())
|
||||||
return;
|
return;
|
||||||
auto coll = getCollectionData();
|
auto coll = getCollectionData();
|
||||||
auto curr = it.data();
|
auto curr = it->data();
|
||||||
auto prev = getPreviousSlot(curr);
|
auto prev = getPreviousSlot(curr);
|
||||||
auto next = curr->next;
|
auto next = curr->next;
|
||||||
if (prev)
|
if (prev)
|
||||||
@ -74,14 +74,14 @@ inline void VariantImpl::removeOne(iterator it) {
|
|||||||
coll->head = next;
|
coll->head = next;
|
||||||
if (next == NULL_SLOT)
|
if (next == NULL_SLOT)
|
||||||
coll->tail = prev.id();
|
coll->tail = prev.id();
|
||||||
freeVariant({it.data(), it.currentId_});
|
freeVariant({it->data(), it.currentId_});
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VariantImpl::removePair(VariantImpl::iterator it) {
|
inline void VariantImpl::removePair(VariantImpl::iterator it) {
|
||||||
if (it.done())
|
if (it.done())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto keySlot = it.data();
|
auto keySlot = it->data();
|
||||||
|
|
||||||
auto valueId = keySlot->next;
|
auto valueId = keySlot->next;
|
||||||
auto valueSlot = getVariant(valueId);
|
auto valueSlot = getVariant(valueId);
|
||||||
|
@ -43,21 +43,13 @@ class CollectionIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const CollectionIterator& other) const {
|
bool operator==(const CollectionIterator& other) const {
|
||||||
return data() == other.data();
|
return value_.data() == other->data();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const CollectionIterator& other) const {
|
bool operator!=(const CollectionIterator& other) const {
|
||||||
return !operator==(other);
|
return !operator==(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantData* data() {
|
|
||||||
return value_.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
const VariantData* data() const {
|
|
||||||
return value_.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CollectionIterator(SlotId slotId, ResourceManager* resources)
|
CollectionIterator(SlotId slotId, ResourceManager* resources)
|
||||||
: value_(resources->getVariant(slotId), resources), currentId_(slotId) {}
|
: value_(resources->getVariant(slotId), resources), currentId_(slotId) {}
|
||||||
|
@ -15,7 +15,7 @@ inline VariantData* VariantImpl::getMember(TAdaptedString key) const {
|
|||||||
if (it.done())
|
if (it.done())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
it.next();
|
it.next();
|
||||||
return it.data();
|
return it->data();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename TAdaptedString>
|
template <typename TAdaptedString>
|
||||||
|
Reference in New Issue
Block a user