MCPcopy Create free account
hub / github.com/Icinga/icinga2 / GetArrayDeletedValues

Method GetArrayDeletedValues

lib/icingadb/icingadb-utility.cpp:454–485  ·  view source on GitHub ↗

Returns the items that exist in "arrayOld" but not in "arrayNew"

Source from the content-addressed store, hash-verified

452
453// Returns the items that exist in "arrayOld" but not in "arrayNew"
454std::vector<Value> IcingaDB::GetArrayDeletedValues(const Array::Ptr& arrayOld, const Array::Ptr& arrayNew) {
455 std::vector<Value> deletedValues;
456
457 if (!arrayOld) {
458 return deletedValues;
459 }
460
461 if (!arrayNew) {
462 ObjectLock olock (arrayOld);
463 return std::vector<Value>(arrayOld->Begin(), arrayOld->End());
464 }
465
466 std::vector<Value> vectorOld;
467 {
468 ObjectLock olock (arrayOld);
469 vectorOld.assign(arrayOld->Begin(), arrayOld->End());
470 }
471 std::sort(vectorOld.begin(), vectorOld.end());
472 vectorOld.erase(std::unique(vectorOld.begin(), vectorOld.end()), vectorOld.end());
473
474 std::vector<Value> vectorNew;
475 {
476 ObjectLock olock (arrayNew);
477 vectorNew.assign(arrayNew->Begin(), arrayNew->End());
478 }
479 std::sort(vectorNew.begin(), vectorNew.end());
480 vectorNew.erase(std::unique(vectorNew.begin(), vectorNew.end()), vectorNew.end());
481
482 std::set_difference(vectorOld.begin(), vectorOld.end(), vectorNew.begin(), vectorNew.end(), std::back_inserter(deletedValues));
483
484 return deletedValues;
485}
486
487// Returns the keys that exist in "dictOld" but not in "dictNew"
488std::vector<String> IcingaDB::GetDictionaryDeletedKeys(const Dictionary::Ptr& dictOld, const Dictionary::Ptr& dictNew) {

Callers

nothing calls this directly

Calls 5

BeginMethod · 0.45
EndMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected