-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind.cpp
38 lines (31 loc) · 787 Bytes
/
Find.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* \file Find.cpp
* \brief
*
* \todo
*/
#include<iostream>
#include<set>
#include<string>
int main()
{
std::set<std::string> setOfNumbers;
// Lets insert four elements
setOfNumbers.insert("first");
setOfNumbers.insert("second");
setOfNumbers.insert("third");
setOfNumbers.insert("first");
// Search for element in set using find member function
std::set<std::string>::iterator it = setOfNumbers.find("second");
if(it != setOfNumbers.end())
std::cout<<"'first' found"<<std::endl;
else
std::cout<<"'first' not found"<<std::endl;
// Search for element in set using find member function
it = setOfNumbers.find("fourth");
if(it != setOfNumbers.end())
std::cout<<"'fourth' found"<<std::endl;
else
std::cout<<"'fourth' not found"<<std::endl;
return 0;
}