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(); } }
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) ); }
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; }