⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testhashmap.cpp

📁 C++高级编程这本书所附的源代码
💻 CPP
字号:
#include "hashmap.h"#include <iostream>#include <map>using namespace std;int main(int argc, char** argv){  hashmap<string, int> myHash;  myHash.insert(make_pair("KeyOne", 100));  myHash.insert(make_pair("KeyTwo", 200));  myHash.insert(make_pair("KeyThree", 300));  for (hashmap<string, int>::iterator it = myHash.begin();       it != myHash.end(); ++it) {    // Use both -> and * to test the operations    cout << it->first << " maps to " << (*it).second << endl;  }  // Create a map with all the elements in the hashmap  map<string, int> myMap(myHash.begin(), myHash.end());  for (map<string, int>::iterator it = myMap.begin();       it != myMap.end(); ++it) {    // Use both -> and * to test the operations    cout << it->first << " maps to " << (*it).second << endl;  }  hashmap<string, int> myHash2;  myHash.swap(myHash2);  hashmap<string, int>myHash3(myHash2);  cout << myHash2.size() << endl;  cout << myHash2.max_size() << endl;  return (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -