|
| |||||||||
| Tags: algorithm, cpp, functions, header files, library, upper_bound |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Use of the upper_bound() in C++
I am the student of the MSC-IT. I can have the practical knowledge of the C++ language programming. Because, I can recently created the project on the Payroll Management in the C++ language programming. Even if I can not know anything about the upper_bound() function in the C++ language programming. So, I want to know about the use of the upper_bound() function of the C++ language. Thus, Anyone can be there who can have the solution for me on the upper_bound() function in the C++ language. |
|
#2
| ||||
| ||||
| The upper_bound()
The upper_bound() function can be used in the C++ language to return an iterator in the format of upper bound. An Iterator that can be to the upper bound place for value in the given specified range. The following can be the syntax of the upper_bound() function of the C++ language : Code: template <class FrwrdItrtr, class S>
FrwrdItrtr upper_bound ( FrwrdItrtr fst, FrwrdItrtr lst,
const S& val );
__________________ Grand Theft Auto 4 PC Video Game |
|
#3
| ||||
| ||||
| Use of the upper_bound()
The following can be the parameters of the upper_bound() function in the C++ language : 1. val : This parameter of the upper_bound() function can contains an element value that can be checked for its upper bound. 2. fst, lst : These parameters of the upper_bound() function can contains the Input iterators to the final and starting positions of the given specified sequence to use. The range used can be [fst,lst) which can contains all the elements between range first and last.
__________________ The FIFA Manager 2009 PC Game |
|
#4
| ||||
| ||||
| Re: Use of the upper_bound() in C++
Here can be a one more example for you to understand more deeply about the upper_bound() function of the C++ language : Code: #pragma warning(disable: 4786)
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;
int main()
{
const int VECTOR_SZ = 8 ;
typedef vector<int > IVector ;
typedef IVector::iterator IVectort ;
IVector Nmbrs(VECTOR_SZ) ;
IVectort st, nd, i, lctn ;
Nmbrs[0] = 4 ;
Nmbrs[1] = 10;
Nmbrs[2] = 10 ;
Nmbrs[3] = 30 ;
Nmbrs[4] = 69 ;
Nmbrs[5] = 70 ;
Nmbrs[6] = 96 ;
Nmbrs[7] = 100;
st = Nmbrs.begin() ;
nd = Nmbrs.end() ;
cout << "Nmbrs { " ;
for(i = st; i != nd; i++)
cout << *i << " " ;
cout << " }\n" << endl ;
lctn = upper_bound(st, nd, 10) ;
cout << "First location element 10 can be inserted in Nmbrs is: "
<< lctn - st << endl ;
} Code: Nmbrs { 4 10 10 30 69 70 96 100 }
First location element 10 can be inserted in Nmbrs is: 1 |
|
#5
| ||||
| ||||
| The upper_bound() in C++
The upper_bound() function can be a type of binary_search() function of the C++ language. The upper_bound() function can searches for the first location that value can be inserted into the range that can be ordered and defined by first and last that could not be confused with the existing ordering; or, similarly, it can returns an iterator to the first element that can not be less than value variable or “end” if all elements can be less than value variable. The upper_bound() function can requires the elements can be in an order. |