=====find=====
Syntax:
#include
The find() function returns an iterator to the matching key/value pair, or an iterator to the end of
the map if key is not found.
find() runs in [[/complexity|logarithmic time]].
For example, the following code uses the find() function to determine how many
times a user entered a certain word:
map stringCounts;
string str;
while( cin >> str ) ++stringCounts[str];
map::iterator iter = stringCounts.find("spoon");
if( iter != stringCounts.end() ) {
cout << "You typed '" << iter->first << "' " << iter->second << " time(s)" << endl;
}
When run with this input:
my spoon is too big. my spoon is TOO big! my SPOON is TOO big! I am a BANANA!
...the above code produces this output:
You typed 'spoon' 2 time(s)