unordered_map<int, Node*> mp; if (mp.find(key) == mp.end()) unordered_map<int, Node*>::iterator it = mp.find(deltmp->key); mp.erase(it); mp.clear(); map[k]++ // this includes the case when count of k from 0 to 1 for (unordered_map<float, int>::iterator it = mp.begin(); it != mp.end(); it++) { int result = num_stack.top(); num_stack.pop(); #define pp pair<int, char> priority_queue<pp, vector<pp>, greater<pp> > que; set<char> visit; if (visit.count(node) != 0) continue; visit.insert(node); bool comp(const IntervalPair &pa, const IntervalPair &pb) { if (pa.start != pb.start) { return pa.start < pb.start; } else { return pb.end < pb.end; } } sort(vec.begin(), vec.end(), comp); sort(vec.begin()+5, vec.begin()+10); que.front();