A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_set_upper_bound.htm below:

C++ Set Library - upper_bound Function

C++ Set Library - upper_bound Function Description

It returns an iterator pointing to the first element in the container which is considered to go after val.

Declaration

Following are the ways in which std::set::upper_bound works in various C++ versions.

C++98
iterator upper_bound (const value_type& val) const;
C++11
  iterator upper_bound (const value_type& val);
const_iterator upper_bound (const value_type& val) const;
Return value

It returns an iterator pointing to the first element in the container which is considered to go after val.

Exceptions

If an exception is thrown, there are no changes in the container.

Time complexity

Time complexity depens on logarithmic.

Example

The following example shows the usage of std::set::upper_bound.

#include <iostream>
#include <set>

int main () {
   std::set<int> myset;
   std::set<int>::iterator itlow,itup;

   for (int i = 1; i < 10; i++) myset.insert(i*10);

   itup = myset.upper_bound (60);

   myset.erase(itup);

   std::cout << "myset contains:";
   for (std::set<int>::iterator it = myset.begin(); it!=myset.end(); ++it)
      std::cout << ' ' << *it;
   std::cout << '\n';

   return 0;
}

The above program will compile and execute properly.

myset contains: 10 20 30 40 50 60 80 90

set.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4