You can use the new range-based for loop:
std::unordered_set<T> mySet;
for (const auto& elem: mySet) {
/* ... process elem ... */
}
Or, you can use the more traditional iterator-based loop:
std::unordered_set<T> mySet;
for (auto itr = mySet.begin(); itr != mySet.end(); ++itr) {
/* ... process *itr ... */
}
Or, if you don’t have auto
support, perhaps because you don’t have C++11 support on your compiler:
std::unordered_set<T> mySet;
for (std::unordered_set<T>::iterator itr = mySet.begin(); itr != mySet.end(); ++itr) {
/* ... process *itr ... */
}