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

Method removeIndex

runtime/3rdparty/jsoncpp/jsoncpp.cpp:3907–3933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3905void Value::removeMember(const String &key) { removeMember(key.c_str()); }
3906
3907bool Value::removeIndex(ArrayIndex index, Value *removed)
3908{
3909 if (type() != arrayValue)
3910 {
3911 return false;
3912 }
3913 CZString key(index);
3914 auto it = value_.map_->find(key);
3915 if (it == value_.map_->end())
3916 {
3917 return false;
3918 }
3919 if (removed)
3920 *removed = it->second;
3921 ArrayIndex oldSize = size();
3922 // shift left all items left, into the place of the "removed"
3923 for (ArrayIndex i = index; i < (oldSize - 1); ++i)
3924 {
3925 CZString keey(i);
3926 (*value_.map_)[keey] = (*this)[i + 1];
3927 }
3928 // erase the last one ("leftover")
3929 CZString keyLast(oldSize - 1);
3930 auto itLast = value_.map_->find(keyLast);
3931 value_.map_->erase(itLast);
3932 return true;
3933}
3934
3935bool Value::isMember(char const *begin, char const *end) const
3936{

Callers

nothing calls this directly

Calls 5

typeFunction · 0.50
sizeFunction · 0.50
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected