C++ set end()C++ set end() function is used to return an iterator which is next to the last entry in the set. Note:- This is a placeholder. No element exists in this location and attempting to access is undefined behavior.SyntaxParameterNone Return valueIt returns an iterator which is pointing next to the last element of the set. ComplexityConstant. Iterator validityNo changes. Data RacesConcurrently accessing the elements of a set is safe. The container is accessed neither the non-const nor the const versions modify the container. Exception SafetyThis member function never throws exception. Example 1Let's see the simple example for end() function: Output: C++ Java SQL In the above example, end() function is used to return an iterator pointing next to the last element in the myset set. Example 2Let's see a simple example to iterate over the set using for-each loop: Output: 0 1 2 4 5 9 Example 3Let's see a simple example to iterate over the set using while loop: Output: Elements of myset are: Aman Deep Nikita Priya Suman In the above example, end() function is used to return an iterator pointing next to the last element in the myset set. Example 4Let's see a simple example: Output: Enter value to find: 60 Element not found. Enter value to find: 30 Element found: 30 In the above example, end() function is used to return an iterator pointing next to the last element in the myset set. Next TopicSet cend() Function |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India