Standard C++ Library Class Reference
const vector<T, Allocator>& y);
Returns true if x is the same as y.
template <class T>
bool operator< (const vector<T, Allocator>& x,
const vector<T, Allocator>& y);
Returns true if the elements contained in x are lexicographically less than the elements
contained in y.
template <class T, class Allocator>
void swap (vector <T, Allocator>& a, vector <T, Allocator>& b);
Efficiently swaps the contents of a and b.
Example
//
// vector.cpp
//
#include <vector>
#include <iostream.h>
ostream& operator<< (ostream& out,
const vector<int, allocator>& v)
{
copy(v.begin(), v.end(), ostream_iterator<int>(out," "));
return out;
}
int main(void)
{
// create a vector of doubles
vector<int, allocator> vi;
int i;
for(i = 0; i < 10; ++i) {
// insert values before the beginning
vi.insert(vi.begin(), i);
}
// print out the vector
cout << vi << endl;
// now let's erase half of the elements
int half = vi.size() >> 1;
for(i = 0; i < half; ++i) {
vi.erase(vi.begin());
}
// print ir out again
cout << vi << endl;
return 0;