Skip to content

Instantly share code, notes, and snippets.

View Devanshi-123's full-sized avatar

Devanshi Goel Devanshi-123

View GitHub Profile
@Devanshi-123
Devanshi-123 / vectorfunctions.csv
Last active June 9, 2020 03:39
Functions on Vectors
Syntax Description
v[i] Returns the ith element of a vector
v.begin() Returns an iterator pointing to the first element of the vector
v.end() Returns an iterator pointing to the last element of the vector
v.size() Returns the number of elements in the vector
v.capacity() Returns the size of underlying array
v.max_size() Returns the maximum number of elements that vector can hold in worst case according to the memory available.
v.push_back() It is used to insert an element at the end of the vector
v.pop_back() It is used to delete the last element of the vector
v.insert(v.begin()+index;value) To insert an element at any given position