In this article we will see how to search if an element is present in an unordered_set or not.

std::unordered_set provides a member function find () that accepts an element of same type as set and search for that element in set.

If element is found then it returns the iterator pointing to that element else it returns an iterator pointing to end of set i.e. unordered_set::endl().

Let’s see an example,

In the above example we tried to search for the 2 elements in set, one was present and other was not.



Click Here to Subscribe for more Articles / Tutorials like this.