本文整理汇总了C++中HashMap::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ HashMap::erase方法的具体用法?C++ HashMap::erase怎么用?C++ HashMap::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashMap
的用法示例。
在下文中一共展示了HashMap::erase方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _Send_back_history
virtual void _Send_back_history(std::shared_ptr<protocol::Invoke> invoke, std::shared_ptr<slave::InvokeHistory> $history)
{
std::shared_ptr<PRInvokeHistory> history = std::dynamic_pointer_cast<PRInvokeHistory>($history);
if (history == nullptr)
return;
// REMOVE UID AND FIRST, LAST INDEXES
for (size_t i = invoke->size(); i < invoke->size(); i--)
{
const std::string &name = invoke->at(i)->getName();
if (name == "_History_uid" || name == "_Piece_first" || name == "_Piece_last")
invoke->erase(invoke->begin() + i);
}
// RE-SEND (DISTRIBUTE) THE PIECE TO OTHER SLAVES
std::thread
(
&base::ParallelSystemArrayBase::sendPieceData, (base::ParallelSystemArrayBase*)system_array_,
invoke, history->getFirst(), history->getLast()
).detach();
// ERASE FROM THE PROGRESS LIST
progress_list_.erase(history->getUID());
};
示例2: GetLastError
static BOOL __stdcall
CryptDestroyHash_done(BOOL retval,
HCRYPTHASH hHash)
{
DWORD err = GetLastError();
int ret_addr = *((DWORD *) ((DWORD) &retval - 4));
if (retval)
{
LOCK();
HashMap::iterator iter = hash_map.find(hHash);
if (iter != hash_map.end())
{
HashContext *ctx = iter->second;
if (!called_internally(ret_addr))
{
message_logger_log(_T("CryptDestroyHash"), (char *) &retval - 4, ctx->get_id(),
MESSAGE_TYPE_MESSAGE, MESSAGE_CTX_INFO, PACKET_DIRECTION_INVALID,
NULL, NULL, NULL, 0, _T("hHash=0x%p"), hHash);
}
hash_map.erase(iter);
delete ctx;
}
UNLOCK();
}
SetLastError(err);
return retval;
}
示例3: _Report_history
virtual void _Report_history(std::shared_ptr<library::XML> xml)
{
library::UniqueWriteLock uk(system_array_->getMutex());
//--------
// CONSTRUCT HISTORY
//--------
std::shared_ptr<PRInvokeHistory> history(new PRInvokeHistory());
history->construct(xml);
// IF THE HISTORY IS NOT EXIST IN PROGRESS, THEN TERMINATE REPORTING
auto progress_it = progress_list_.find(history->getUID());
if (progress_it == progress_list_.end())
return;
// ARCHIVE FIRST AND LAST INDEX
history->first_ = std::dynamic_pointer_cast<PRInvokeHistory>(progress_it->second.second)->getFirst();
history->last_ = std::dynamic_pointer_cast<PRInvokeHistory>(progress_it->second.second)->getLast();
// ERASE FROM ORDINARY PROGRESS AND MIGRATE TO THE HISTORY
progress_list_.erase(progress_it);
history_list_.insert({ history->getUID(), history });
// NOTIFY TO THE MANAGER, SYSTEM_ARRAY
((base::ParallelSystemArrayBase*)system_array_)->_Complete_history(history);
};
示例4: _Complete_history
/* ---------------------------------------------------------
INVOKE MESSAGE CHAIN
--------------------------------------------------------- */
void _Complete_history(size_t uid)
{
std::unique_lock<std::mutex> uk(mtx_);
//--------
// NEED TO REDEFINE START AND END TIME
//--------
// NO SUCH HISTORY; THE PROCESS HAD DONE ONLY IN THIS MEDIATOR LEVEL.
if (progress_list_.has(uid) == false)
return;
// COMPLETE THE HISTORY
std::shared_ptr<slave::InvokeHistory> history = progress_list_.get(uid);
history->complete();
// ERASE THE HISTORY ON PROGRESS LIST
progress_list_.erase(uid);
// REPORT THE HISTORY TO MASTER
std::thread(&MediatorSystem::sendData, this, history->toInvoke()).detach();
};
示例5: hashMapInt
void hashMapInt() {
HashMap<int, int> m;
//insert
assert("HashMap::insert()", m.insert(2, 5).second);
assert("HashMap::insert()", m.insert(3, 6).second);
assert("HashMap::insert()", m.insert(4, 7).second);
assert("HashMap::size()", m.size() == 3);
//dupe insert
Pair<HashMap<int, int>::Iterator, bool> res = m.insert(4, 8);
assert("HashMap::insert()", !res.second);
assert("HashMap::insert()", res.first != m.end());
assert("HashMap::insert()", res.first->first == 4);
assert("HashMap::insert()", res.first->second == 7);
//find
HashMap<int, int>::Iterator itr = m.find(3);
assert("HashMap::find()", itr != m.end());
assert("HashMap::find()", itr->first == 3);
assert("HashMap::find()", itr->second == 6);
//iterate
itr = m.begin();
assert("HashMap::begin()", itr != m.end());
++itr;
itr++;
++itr;
assert("HashMap::Iterator", itr == m.end());
//const iterator
HashMap<int, int>::ConstIterator citr = m.find(2);
assert("cHashMap::find()", citr != m.end());
assert("cHashMap::find()", citr->first == 2);
assert("cHashMap::find()", citr->second == 5);
citr = m.begin();
assert("cHashMap::begin()", citr != m.end());
++citr;
citr++;
++citr;
assert("cHashMap::Iterator", citr == m.end());
//erase
assert("HashMap::erase()", m.erase(3));
assert("HashMap::erase()", m.size() == 2);
//copy constuctor
HashMap<int, int> copy(m);
assert("HashMap::HashMap(HashMap)", copy.size() == 2);
//erase by iterator
m.erase(m.find(2));
assert("HashMap::erase(Iterator)", m.size() == 1);
//clear
m.clear();
assert("HashMap::clear()", m.size() == 0);
itr = m.find(4);
assert("HashMap::clear()", itr == m.end());
assert("HashMap::clear()", m.begin() == m.end());
//assignment operator
m = copy;
assert("HashMap::operator=", m.size() == 2);
//square bracket operator
m[9] = 10;
assert("HashMap::operator[]", m[2] == 5);
}
示例6: hashMap
void hashMap() {
HashMap<String, String> m;
//insert
assert("HashMap::insert()", m.insert("foo", "F00").second);
assert("HashMap::insert()", m.insert("bar", "B4R").second);
assert("HashMap::insert()", m.insert("baz", "B4Z").second);
assert("HashMap::size()", m.size() == 3);
//dupe insert
Pair<HashMap<String, String>::Iterator, bool> res = m.insert("foo", "whatev");
assert("HashMap::insert()", !res.second);
assert("HashMap::insert()", res.first != m.end());
assert("HashMap::insert()", res.first->first == "foo");
assert("HashMap::insert()", res.first->second == "F00");
//find
HashMap<String, String>::Iterator itr = m.find("bar");
assert("HashMap::find()", itr != m.end());
assert("HashMap::find()", itr->first == "bar");
assert("HashMap::find()", itr->second == "B4R");
//iterate
itr = m.begin();
assert("HashMap::begin()", itr != m.end());
++itr;
itr++;
++itr;
assert("HashMap::Iterator", itr == m.end());
//const iterator
HashMap<String, String>::ConstIterator citr = m.find("baz");
assert("cHashMap::find()", citr != m.end());
assert("cHashMap::find()", citr->first == "baz");
assert("cHashMap::find()", citr->second == "B4Z");
citr = m.begin();
assert("cHashMap::begin()", citr != m.end());
++citr;
citr++;
++citr;
assert("cHashMap::Iterator", citr == m.end());
//erase
assert("HashMap::erase()", m.erase("bar"));
assert("HashMap::erase()", m.size() == 2);
//copy constuctor
HashMap<String, String> copy(m);
assert("HashMap::HashMap(HashMap)", copy.size() == 2);
//erase by iterator
m.erase(m.find("baz"));
assert("HashMap::erase(Iterator)", m.size() == 1);
//clear
m.clear();
assert("HashMap::clear()", m.size() == 0);
itr = m.find("baz");
assert("HashMap::clear()", itr == m.end());
assert("HashMap::clear()", m.begin() == m.end());
//assignment operator
m = copy;
assert("HashMap::operator=", m.size() == 2);
//square bracket operator
m["norg"] = "N07G";
assert("HashMap::operator[]", m["foo"] == "F00");
}
示例7: log_eventQueue
void HaggleKernel::log_eventQueue(Metadata *m) {
HashMap<string, size_t> counts;
HashMap<string, size_t>::iterator cit;
Heap theHeap;
Metadata *dm = m->addMetadata("Events");
if (!dm) {
return;
}
List<Event *> list = getEventList();
for (List<Event *>::iterator it = list.begin(); it != list.end(); it++) {
Event *e = *it;
theHeap.insert(*it);
cit = counts.find(e->getName());
if (cit == counts.end()) {
counts.insert(make_pair(e->getName(), 1));
} else {
size_t count = (*cit).second;
counts.erase(cit);
counts.insert(make_pair(e->getName(), count+1));
}
}
for (size_t i = 0; i < list.size(); i++) {
Event *e = static_cast<Event *>(theHeap.extractFirst());
if (e) {
if (i < 200) {
Metadata *dmm = dm->addMetadata("Event");
dmm->setParameter("name", e->getName());
dmm->setParameter("time", e->getTimeout().getAsString());
dmm->setParameter("canceled", e->isCanceled() ? "true" : "false");
if (e->getDataObject()) {
dmm->setParameter("dObj", e->getDataObject()->getIdStr());
}
if (e->getNode()) {
dmm->setParameter("node", e->getNode()->getIdStr());
}
if (e->getInterface()) {
dmm->setParameter("iface", e->getInterface()->getIdentifierStr());
}
if (e->getNodeList().size() > 0) {
dmm->setParameter("nodeListSize", e->getNodeList().size());
}
if (e->getDataObjectList().size() > 0) {
dmm->setParameter("dataObjectListSize", e->getDataObjectList().size());
}
if (strcmp(e->getName(), "BFRemoveDelay") == 0) {
const DataObjectId_t *id = (DataObjectId_t *) e->getData();
if (id) {
dmm->setParameter("dObj", DataObject::idString(*id));
}
}
}
delete e;
}
}
dm = m->addMetadata("Counts");
if (!dm) {
return;
}
for (cit = counts.begin(); cit != counts.end(); cit++) {
Metadata *dmm = dm->addMetadata("Event");
if (dmm) {
dmm->setParameter("name", (*cit).first);
dmm->setParameter("count", (*cit).second);
}
}
}
示例8: _Report_history
void _Report_history(std::shared_ptr<DSInvokeHistory> history)
{
// ERASE FROM ORDINARY PROGRESS AND MIGRATE TO THE HISTORY
progress_list_.erase(history->getUID());
history_list_.emplace(history->getUID(), history);
};