#include #include #include #include "Hash.hpp" int main() { Hash hash(32); std::string town; unsigned int population; std::ifstream cities("cities"); while (cities >> town && cities >> population) { bool ok; std::tie(std::ignore, ok) = hash.insert(std::make_pair(town, population)); if (!ok) { std::cerr << "insertion of " << town << " failed." << std::endl; } } std::cout << hash.size() << " objects loaded from 'cities'." << std::endl; while (std::cin >> town) { auto it = hash.find(town); if (it == hash.end()) { std::cerr << town << " not found." << std::endl; } else { // std::cout << it->second.population << std::endl; std::cout << it->second << std::endl; hash.erase(it); std::cout << hash.size() << " objects left." << std::endl; } } for (auto& object: hash) { std::cout << object.first << " " << object.second << std::endl; } }