本文整理汇总了C++中MyMap::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMap::clear方法的具体用法?C++ MyMap::clear怎么用?C++ MyMap::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMap
的用法示例。
在下文中一共展示了MyMap::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char * argv[]) {
if (argc == 0) {
cout << "usage: " << argv[0] << "[File1 [File2 [File3 [...]]]]" << endl;
}
for (int i = 1; i < argc; i++) {
cout << "File: " << argv[i] << endl;
printNames(argv[i]);
MyMap::iterator it = names.begin();
while (it != names.end()) {
//cout << it->first << ": " << it->second << endl;
sortiert.push_back(it);
it++;
}
//partial_sort (sortiert.begin(), sortiert.bein() + 20, sortiert.end(), mySort);
partial_sort (sortiert.begin(), sortiert.begin() + 20, sortiert.end(), myObject);
size_t c = 0;
for (MyVec::iterator it = sortiert.begin(); it != sortiert.end() && c < 20; it++, c++) {
cout << (*it)->first << ": " << (*it)->second << endl;
}
cout << "==============================" << endl;
names.clear();
}
}
示例2: clear
void tst_QMap::clear()
{
{
MyMap map;
map.clear();
QVERIFY( map.isEmpty() );
map.insert( "key", MyClass( "value" ) );
map.clear();
QVERIFY( map.isEmpty() );
map.insert( "key0", MyClass( "value0" ) );
map.insert( "key0", MyClass( "value1" ) );
map.insert( "key1", MyClass( "value2" ) );
map.clear();
QVERIFY( map.isEmpty() );
}
QCOMPARE( MyClass::count, int(0) );
}
示例3: loadMyMap
bool loadMyMap(string filename, MyMap<KeyType, ValueType>& m)
{
m.clear();
ifstream stream("filename");
if (!stream) return false;
int size = m.size();
if (!readItem(stream, size)) return false; // Read the number of associations in m from stream, returning false if we can't
KeyType x;
ValueType y;
for (int i = 0; i < size; i++) {
if (!readItem(stream, x)) return false;
stream.ignore(10000, '\n');
if (!readItem(stream, y)) return false;
stream.ignore(10000, '\n');
m.associate(x, y);
}
return true;
}