MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / removeIndex

Method removeIndex

Sources/Dependencies/jsoncpp/value.cpp:1368–1390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1366#endif
1367
1368 bool Value::removeIndex(ArrayIndex index, Value* removed) {
1369 if (type() != arrayValue) {
1370 return false;
1371 }
1372 CZString key(index);
1373 auto it = value_.map_->find(key);
1374 if (it == value_.map_->end()) {
1375 return false;
1376 }
1377 if (removed)
1378 *removed = std::move(it->second);
1379 ArrayIndex oldSize = size();
1380 // shift left all items left, into the place of the "removed"
1381 for (ArrayIndex i = index; i < (oldSize - 1); ++i) {
1382 CZString keey(i);
1383 (*value_.map_)[keey] = (*this)[i + 1];
1384 }
1385 // erase the last one ("leftover")
1386 CZString keyLast(oldSize - 1);
1387 auto itLast = value_.map_->find(keyLast);
1388 value_.map_->erase(itLast);
1389 return true;
1390 }
1391
1392 bool Value::isMember(char const* begin, char const* end) const {
1393 Value const* value = find(begin, end);

Callers

nothing calls this directly

Calls 5

typeClass · 0.85
sizeFunction · 0.85
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected