Question : find with hash set
Answered by : happy-horse-tiuyuntuatcm
#include <unordered_set>
#include <string>
#include <iostream>
int main() { std::unordered_set<std::string> planets{ {"Venus"}, {"Earth"}, {"Mars"}, }; auto it = planets.find("Earth"); if (it != planets.end()) { std::cout << *it << "\n"; } else { std::cout << "No such planet.\n"; } it = planets.find("PlanetX"); if (it != planets.end()) { std::cout << *it << "\n"; } else { std::cout << "No such planet.\n"; }
}
Source : https://cppbyexample.com/hash_set_find.html | Last Update : Sat, 04 Dec 21