Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
equal_range.cpp
Go to the documentation of this file.
1
30#include <algorithm>
31#include <functional>
32#include <iostream>
33#include <vector>
34
35#include <examples.h>
36
37
38int main ()
39{
40 // Typedef for convenience.
41 typedef std::vector<int, std::allocator<int> > Vector;
42
43 Vector::value_type arr[] = { 0, 1, 2, 2, 3, 4, 2, 2, 2, 6, 7 };
44
45 // Set up a vector.
46 Vector v1 (arr, arr + sizeof arr / sizeof *arr);
47
48 // Try equal_range variants.
49 std::pair<Vector::iterator, Vector::iterator> p1 =
50 std::equal_range (v1.begin (), v1.end (), 3);
51
52 std::pair<Vector::iterator, Vector::iterator> p2 =
53 std::equal_range (v1.begin (), v1.end (), 2,
54 std::less<Vector::value_type> ());
55
56 // Output results.
57 std::cout << "\nThe equal range for 3 is: "
58 << "(" << *p1.first << " , "
59 << *p1.second << ")" << std::endl;
60
61 std::cout << "\nThe equal range for 2 is: "
62 << "(" << *p2.first << " , "
63 << *p2.second << ")" << std::endl;
64
65 return 0;
66}
#define p2
Definition 17.names.cpp:265
#define p1
Definition 17.names.cpp:239
#define v1
Definition 17.names.cpp:245
std::vector< UserClass, std::allocator< UserClass > > Vector
int main()