Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
examples
manual
ul_bound.cpp
Go to the documentation of this file.
1
29
#include <vector>
30
#include <algorithm>
31
#include <functional>
32
#include <iostream>
33
34
int
main
()
35
{
36
typedef
std::vector<int, std::allocator<int> >
Vector
;
37
typedef
Vector::const_iterator
Iterator
;
38
39
const
int
a
[] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7 };
40
41
// Set up a vector.
42
const
Vector
v
(
a
,
a
+
sizeof
a
/
sizeof
*
a
);
43
44
// Try lower_bound variants.
45
Iterator
it1 = std::lower_bound (
v
.begin (),
v
.end (), 3);
46
Iterator
it2 = std::lower_bound (
v
.begin (),
v
.end (), 2,
47
std::less<int>());
48
49
// Try upper_bound variants.
50
Iterator
it3 = std::upper_bound (
v
.begin (),
v
.end (), 3);
51
Iterator
it4 = std::upper_bound (
v
.begin (),
v
.end (), 2,
52
std::less<int>());
53
54
std::cout <<
"\n\nThe upper and lower bounds of 3: ( "
55
<< *it1 <<
" , "
<< *it3
56
<<
" ]\n\n\nThe upper and lower bounds of 2: ( "
57
<< *it2 <<
" , "
<< *it4 <<
" ]\n"
;
58
59
return
0;
60
}
Iterator
InputIter< UserClass > Iterator
Definition
0.inputiter.cpp:83
v
#define v
Definition
17.names.cpp:138
a
#define a
Definition
17.names.cpp:109
Vector
std::vector< UserClass, std::allocator< UserClass > > Vector
Definition
23.vector.capacity.cpp:43
InputIter
Definition
rw_alg_test.h:379
main
int main()
Definition
ul_bound.cpp:34
Generated by
1.9.8