void plKeyCollector::del(plKey key) { std::vector<plKey>& keyList = keys[key->getLocation()][key->getType()]; std::vector<plKey>::iterator it = keyList.begin(); size_t sub = 0; while (it != keyList.end()) { if ((*it) == key) { it = keyList.erase(it); sub++; } else { (*it)->setID((*it)->getID() - sub); it++; } } if (keyList.empty()) keys[key->getLocation()].erase(key->getType()); if (keys[key->getLocation()].empty()) keys.erase(key->getLocation()); if (key.Exists() && key.isLoaded()) { key->deleteObj(); } }