|
| |||||||||
| Tags: algorithm, cpp, functions, header files, library, lower_bound |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| lower_bound() function of C++
I can have to complete my project in 2 days. But I can not know anything about the lower bound function of the C++ language. Because of that I am finding the difficulties in completing my project on time. So, I would like to know about the lower_bound() function of the C++ language. If you can know about the lower_bound() function then reply me as early as you can. Good Day!!! |
|
#2
| |||
| |||
| lower_bound() function of C++
I think you can hase to go though the follwing code of lines that can describes you what is the use and how to implement the lwer_bound() function in the C++ programming : Code: #include <iostream>
#include <algorithm>
#include <sector>
using namespace std;
int main ()
{
int mint[] = {10,20,30,30,20,10,10,20};
sector<int> s(mint,mint+8);
sector<int>::iterator lw,p;
sort (s.begin(), s.end());
lw=lwer_bound (s.begin(), s.end(), 20);
p= pper_bound (s.begin(), s.end(), 20);
cout << "lwer_bound at position " << int(lw- s.begin()) << endl;
cout << "pper_bound at position " << int(p - s.begin()) << endl;
return 0;
} Code: lwer_bound at position 3 pper_bound at position 6 |
|
#3
| ||||
| ||||
| The lower_bound() function
The lower_bound() function can be used to return an iterator into the lower bound. The lower_bound() function can returns an iterator that can be pointing to the first element in the given range [first,last) that can be sorted, which can not compare less than value. The comparison can be done using either operator< for the first version or comp for the second version. |
|
#4
| ||||
| ||||
| lower_bound() function
The lower_bound() function can be used to return the iterator to the lower bound. An iterator to the lower bound place for value in the given specified range. The following can be the syntax of the lower_bound() function of the C++ language : Code: template <class FrwrdItrtr, class S>
FrwrdItrtr lower_bound ( FrwrdItrtr fst, FrwrdItrtr lst,
const S& val ); |
|
#5
| ||||
| ||||
| Re: lower_bound() function of C++
The following can be the parameters of the lower_bound() function in the C++ language : 1. val : This parameter of the lower_bound() function can contains an element value that can be checked for its lower bound. 2. fst, lst : These parameters of the lower_bound() function can contains the forward iterators to the final and starting positions of the given sequence to use. |
|
#6
| ||||
| ||||
| Re: lower_bound() function of C++
Here can be a one more example for you to understand more deeply about the lower_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 start, end, it, location ;
Nmbrs[0] = 4 ;
Nmbrs[1] = 10;
Nmbrs[2] = 10 ;
Nmbrs[3] = 30 ;
Nmbrs[4] = 69 ;
Nmbrs[5] = 70 ;
Nmbrs[6] = 96 ;
Nmbrs[7] = 100;
start = Nmbrs.begin() ;
end = Nmbrs.end() ;
cout << "Nmbrs { " ;
for(it = start; it != end; it++)
cout << *it << " " ;
cout << " }\n" << endl ;
location = lower_bound(start, end, 10) ;
cout << "First location element 10 can be inserted in Nmbrs is: "
<< location - start << endl ;
} Code: Nmbrs { 4 10 10 30 69 70 96 100 }
First location element 10 can be inserted in Nmbrs is: 1
__________________ Grand Theft Auto 4 PC Video Game |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "lower_bound() function of C++" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| c++ equivalent function to the c-function 'sprintf | Dilbert | Software Development | 6 | 13-12-2011 04:03 PM |
| c# function equivalent to gettime function in javascript | Omaar | Software Development | 4 | 10-03-2010 10:44 PM |
| How to pass function with parameters to another function in PHP? | Linoo | Software Development | 5 | 27-02-2010 07:52 PM |
| How does abstract function differs from virtual function? | Maddox G | Software Development | 5 | 29-01-2010 11:32 AM |
| Function keys don't function under windows XP | GunFighter | Hardware Peripherals | 3 | 09-04-2009 12:07 AM |