本文整理汇总了C++中std::tr1::unordered_map::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map::empty方法的具体用法?C++ unordered_map::empty怎么用?C++ unordered_map::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::tr1::unordered_map
的用法示例。
在下文中一共展示了unordered_map::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: it
inline void operator<< (object::with_zone& o, const std::tr1::unordered_map<K,V>& v)
{
o.type = type::MAP;
if(v.empty()) {
o.via.map.ptr = NULL;
o.via.map.size = 0;
} else {
object_kv* p = (object_kv*)o.zone->malloc(sizeof(object_kv)*v.size());
object_kv* const pend = p + v.size();
o.via.map.ptr = p;
o.via.map.size = v.size();
typename std::tr1::unordered_map<K,V>::const_iterator it(v.begin());
do {
p->key = object(it->first, o.zone);
p->val = object(it->second, o.zone);
++p;
++it;
} while(p < pend);
}
}
示例2: displayMulti
//Implementation of displayMulti()
void Engine::displayMulti(std::tr1::unordered_map<string, unsigned int> table) {
// If the map is empty there is nothing to be done.
if(table.empty()) {
cout << "No movies matched your search. Sorry" << endl << endl ;
return ;
}
std::tr1::unordered_map<string, unsigned int>::iterator it2 ;
string big ;
// Iterate three times to get the three movies with highest frequencies
for(int i = 0 ; i < 3 ; i++) {
// If the intersection is empty the job is done
if(table.size() == 0) {
cout << "No more movies." << endl << endl ;
return ;
}
// Assume the movie with highest frequency is the first one
big = table.begin()->first ;
// Iterate through the rest of the movies and if one with higher frequency
// is found swap it with big
for(it2 = table.begin() ; it2 != table.end() ; it2++)
if(table[big] < it2->second)
big = it2->first;
// Print the movie with highest frequency
cout << "Movie " << i+1 << ": " << big << endl ;
// Erase that movie from the map
table.erase(big) ;
}
cout << endl ;
}