void CEventHandler::ListRemove(EventClientList& ecList, CEventClient* ec) { // FIXME: efficient, hardly EventClientList newList; for (int i = 0; i < ecList.size(); i++) { if (ec != ecList[i]) { newList.push_back(ecList[i]); } } ecList = newList; }
void CEventHandler::ListInsert(EventClientList& ecList, CEventClient* ec) { EventClientList::iterator it; for (it = ecList.begin(); it != ecList.end(); ++it) { const CEventClient* ecIt = *it; if (ec == ecIt) { return; // already in the list } else if ((ec->GetOrder() < ecIt->GetOrder()) || ((ec->GetOrder() == ecIt->GetOrder()) && (ec->GetName() < ecIt->GetName()))) { // should not happen ecList.insert(it, ec); return; } } ecList.push_back(ec); }
void CEventHandler::ListRemove(EventClientList& ecList, CEventClient* ec) { // FIXME: efficient, hardly EventClientList newList; newList.reserve(ecList.size()); for (size_t i = 0; i < ecList.size(); i++) { if (ec != ecList[i]) { newList.push_back(ecList[i]); } } ecList.swap(newList); }