C++ multiset find()C++ multiset find() function is used to find an element with the given value val. If it finds the element, then it returns an iterator pointing to the element otherwise, it returns an iterator pointing to the end of the multiset i.e. multiset::end(). SyntaxParameterval: specifies the value to be searched in the multiset container. Return valueIf it finds the element then it returns an iterator pointing to the element otherwise, it returns an iterator pointing to the end of the multiset i.e. multiset::end(). ComplexityLogarithmic in size. Iterator validityNo changes. Data RacesThe container is accessed (neither the constant nor the non-constant versions modify the container. No mapped values are accessed: concurrently accessing and modifying the elements is safe. Exception SafetyIf an exception is thrown, there are no changes in the multiset container. Example 1Let's see the simple example to find the element with the given key value: Output: Iterator points to 300 Example 2Let's see a simple example to find the element: Output: Element not found In the above example, find() function find the key value e in the multiset m, if it is not found in the multiset then it will return a not found message otherwise, it will display the multiset. Example 3Let's see a simple example: Output: Enter the element which you want to search: b b found and the value is b In the above example, find() function is used to find the element according to user's given value. Example 4Let's see a simple example: Output: mymultiset contains: 10 20 30 50 70 80 90 100
Next TopicC++ multiset
|