MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / removeIndex

Method removeIndex

edrav2/eprj/jsoncpp/src/lib_json/json_value.cpp:1260–1282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1258}
1259
1260bool Value::removeIndex(ArrayIndex index, Value* removed) {
1261 if (type_ != arrayValue) {
1262 return false;
1263 }
1264 CZString key(index);
1265 auto it = value_.map_->find(key);
1266 if (it == value_.map_->end()) {
1267 return false;
1268 }
1269 if (removed)
1270 *removed = it->second;
1271 ArrayIndex oldSize = size();
1272 // shift left all items left, into the place of the "removed"
1273 for (ArrayIndex i = index; i < (oldSize - 1); ++i) {
1274 CZString keey(i);
1275 (*value_.map_)[keey] = (*this)[i + 1];
1276 }
1277 // erase the last one ("leftover")
1278 CZString keyLast(oldSize - 1);
1279 auto itLast = value_.map_->find(keyLast);
1280 value_.map_->erase(itLast);
1281 return true;
1282}
1283
1284#ifdef JSON_USE_CPPTL
1285Value Value::get(const CppTL::ConstString& key,

Callers 1

JSONTEST_FIXTUREFunction · 0.80

Calls 4

sizeClass · 0.50
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected