Skip to main content

6.5) Other Vector Operations


  • The size method returns the number of elements in the vector
  • The capacity method returns the number of elements that could be held in currently allocated storage
  • The resize method changes the number of elements in the vector
  • The swap method swaps this vector's contents with those of another vector:
  • vector<int> p, q;
    ...
    p.swap(q);
    
  • The == and != operators work for vectors, testing whether or not two vectors are of same size and contain the same elements
  • <, <=, >, >= work, doing a lexicographical comparison