MCPcopy Create free account
hub / github.com/SOUI2/soui / removeIndex

Method removeIndex

third-part/jsoncpp/src/lib_json/json_value.cpp:1205–1226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1203}
1204
1205bool Value::removeIndex(ArrayIndex index, Value* removed) {
1206 if (type_ != arrayValue) {
1207 return false;
1208 }
1209 CZString key(index);
1210 ObjectValues::iterator it = value_.map_->find(key);
1211 if (it == value_.map_->end()) {
1212 return false;
1213 }
1214 *removed = it->second;
1215 ArrayIndex oldSize = size();
1216 // shift left all items left, into the place of the "removed"
1217 for (ArrayIndex i = index; i < (oldSize - 1); ++i){
1218 CZString keey(i);
1219 (*value_.map_)[keey] = (*this)[i + 1];
1220 }
1221 // erase the last one ("leftover")
1222 CZString keyLast(oldSize - 1);
1223 ObjectValues::iterator itLast = value_.map_->find(keyLast);
1224 value_.map_->erase(itLast);
1225 return true;
1226}
1227
1228#ifdef JSON_USE_CPPTL
1229Value Value::get(const CppTL::ConstString& key,

Callers 1

JSONTEST_FIXTUREFunction · 0.80

Calls 3

sizeFunction · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected