Find With Hash Set

[Solved] Find With Hash Set | Scala - Code Explorer | yomemimo.com
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

Answers related to find with hash set

Code Explorer Popular Question For Scala