MCPcopy Create free account
hub / github.com/Samsung/UTopia / removeIndex

Method removeIndex

external/jsoncpp/jsoncpp.cpp:3592–3614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3590void Value::removeMember(const String &key) { removeMember(key.c_str()); }
3591
3592bool Value::removeIndex(ArrayIndex index, Value *removed) {
3593 if (type() != arrayValue) {
3594 return false;
3595 }
3596 CZString key(index);
3597 auto it = value_.map_->find(key);
3598 if (it == value_.map_->end()) {
3599 return false;
3600 }
3601 if (removed)
3602 *removed = it->second;
3603 ArrayIndex oldSize = size();
3604 // shift left all items left, into the place of the "removed"
3605 for (ArrayIndex i = index; i < (oldSize - 1); ++i) {
3606 CZString keey(i);
3607 (*value_.map_)[keey] = (*this)[i + 1];
3608 }
3609 // erase the last one ("leftover")
3610 CZString keyLast(oldSize - 1);
3611 auto itLast = value_.map_->find(keyLast);
3612 value_.map_->erase(itLast);
3613 return true;
3614}
3615
3616#ifdef JSON_USE_CPPTL
3617Value Value::get(const CppTL::ConstString &key,

Callers

nothing calls this directly

Calls 2

endMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected