

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
upper_bound in C++
Here we will see that is the upper_bound() function in C++ STL. This function returns an iterator that points to the first element in the container, which is considered to go after val. The syntax is like:
iterator upper_bound (const value_type& val); const_iterator upper_bound (const value_type& val) const;
The return value is an iterator, pointing to the first element in the container which is considered to go after val.
Example
#include <iostream> #include <set> using namespace std; int main () { set<int> myset; set<int>::iterator itlow,itup; for (int i = 1; i < 10; i++) myset.insert(i*10); itup = myset.upper_bound (60); myset.erase(itup); cout << "myset contains:"; for (set<int>::iterator it = myset.begin(); it!=myset.end(); ++it) cout << ' ' << *it; }
Output
myset contains: 10 20 30 40 50 60 80 90
- Related Questions & Answers
- Upper bound and Lower bound for non increasing vector in C++
- Construct a distinct elements array with given size, sum and element upper bound in Python
- Lower bound in C++
- Python – Custom Lower bound a List
- Converting to upper case in Java.
- Convert vowels from upper to lower or lower to upper using C program
- 0/1 Knapsack using Branch and Bound in C++
- Finding upper elements in array in JavaScript
- How to use upper () in Android sqlite?
- Alternate Lower Upper String Sort in C++
- Swap Upper diagonal with Lower in C++
- 0/1 Knapsack using Branch and Bound in C/C++?
- Greatest number divisible by n within a bound in JavaScript
- Python Pandas - Get the right bound for the interval
- Python Pandas - Get the left bound for the IntervalIndex
- Python Pandas - Get the right bound for the IntervalIndex
Advertisements