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
rotate.cpp
Go to the documentation of this file.
1
29
#include <algorithm>
// for rotate
30
#include <iostream>
// for cout, endl
31
#include <iterator>
// for ostream_iterator
32
#include <vector>
// for vector
33
34
#include <
examples.h
>
35
36
37
int
main
()
38
{
39
typedef
std::vector<int, std::allocator<int> >
Vector
;
40
41
// Initialize a vector with an array of integers.
42
const
Vector::value_type arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
43
Vector
v
(arr + 0, arr +
sizeof
arr /
sizeof
*arr);
44
45
typedef
std::ostream_iterator<int, char, std::char_traits<char> >
Iter
;
46
47
// Print out elements in original (sorted) order.
48
std::cout <<
"Elements before rotate: \n "
;
49
std::copy (
v
.begin (),
v
.end (),
Iter
(std::cout,
" "
));
50
51
// Rotate the elements.
52
std::rotate (
v
.begin (),
v
.begin () + 4,
v
.end ());
53
54
// Print out the rotated elements.
55
std::cout <<
"\n\nElements after rotate: \n "
;
56
std::copy (
v
.begin (),
v
.end (),
Iter
(std::cout,
" "
));
57
std::cout << std::endl;
58
59
return
0;
60
}
v
#define v
Definition
17.names.cpp:138
Vector
std::vector< UserClass, std::allocator< UserClass > > Vector
Definition
23.vector.capacity.cpp:43
Iter
std::ostream_iterator< int, char, std::char_traits< char > > Iter
Definition
alg7.cpp:64
examples.h
main
int main()
Definition
rotate.cpp:37
Generated by
1.9.8