methods available for a stl vector

Methods available for an STL vector in C++

  • push_back(): Adds an element to the end of the vector.
  • pop_back(): Removes the last element from the vector.
  • size(): Returns the number of elements in the vector.
  • empty(): Returns true if the vector is empty, false otherwise.
  • clear(): Removes all elements from the vector.
  • resize(): Changes the size of the vector.
  • reserve(): Requests that the vector capacity be at least enough to contain a specified number of elements.
  • at(): Accesses the element at a specified position with bounds checking.
  • front(): Accesses the first element in the vector.
  • back(): Accesses the last element in the vector.
  • begin(): Returns an iterator to the beginning.
  • end(): Returns an iterator to the end.
  • insert(): Inserts elements into the vector at a specified position.
  • erase(): Removes elements from the vector at a specified position or range.
  • emplace(): Constructs and inserts an element at a specified position.
  • emplace_back(): Constructs and appends an element to the end.
  • swap(): Swaps the contents of two vectors.

These methods provide various ways to manipulate and access elements in an STL vector in C++.