Search
 
SCRIPT & CODE EXAMPLE
 

CPP

stl vector

refer to this link :-
https://www.geeksforgeeks.org/vector-in-cpp-stl/

Capacity

size() – Returns the number of elements in the vector.
max_size() – Returns the maximum number of elements that the vector can hold.
capacity() – Returns the size of the storage space currently allocated to the vector expressed as number of elements.
resize(n) – Resizes the container so that it contains ‘n’ elements.
empty() – Returns whether the container is empty.
shrink_to_fit() – Reduces the capacity of the container to fit its size and destroys all elements beyond the capacity.
reserve() – Requests that the vector capacity be at least enough to contain n elements.

Element access:

reference operator [g] – Returns a reference to the element at position ‘g’ in the vector
at(g) – Returns a reference to the element at position ‘g’ in the vector
front() – Returns a reference to the first element in the vector
back() – Returns a reference to the last element in the vector
data() – Returns a direct pointer to the memory array used internally by the vector to store its owned elements.

Modifiers:

assign() – It assigns new value to the vector elements by replacing old ones
push_back() – It push the elements into a vector from the back
pop_back() – It is used to pop or remove elements from a vector from the back.
insert() – It inserts new elements before the element at the specified position
erase() – It is used to remove elements from a container from the specified position or range.
swap() – It is used to swap the contents of one vector with another vector of same type. Sizes may differ.
clear() – It is used to remove all the elements of the vector container
emplace() – It extends the container by inserting new element at position
emplace_back() – It is used to insert a new element into the vector container, the new element is added to the end of the vector

All Vector Functions :

vector::begin() and vector::end()
vector rbegin() and rend()
vector::cbegin() and vector::cend()
vector::crend() and vector::crbegin()
vector::assign()
vector::at()
vector::back()
vector::capacity()
vector::clear()
vector::push_back()
vector::pop_back()
vector::empty()
vector::erase()
vector::size()
vector::swap()
vector::reserve()
vector::resize()
vector::shrink_to_fit()
vector::operator=
vector::operator[]
vector::front()
vector::data()
vector::emplace_back()
vector::emplace()
vector::max_size()
vector::insert()

Comment

PREVIOUS NEXT
Code Example
Cpp :: unreal engine c++ 
Cpp :: how to compile opencv c++ in ubuntu 
Cpp :: lua table contains 
Cpp :: length of string in c++ 
Cpp :: how to add c++14 in sublime text 
Cpp :: Program To Calculate Number Power Using Recursion In C++. The power number should always be positive integer. 
Cpp :: new float array c++ 
Cpp :: Sort html elements in Jquery on condition 
Cpp :: new c++ 
Cpp :: c++ do every 1 minutes 
Cpp :: classes constructor in c++ 
Cpp :: c++ char array size 
Cpp :: c++ hash combine 
Cpp :: life the universe and everything solution c++ 
Cpp :: quick sort 
Cpp :: print hello world in c++ 
Cpp :: c++ preprocessor operations 
Cpp :: stl c++ 
Cpp :: vectors c++ 
Cpp :: double array size c++ 
Cpp :: heap buffer overflow in c 
Cpp :: visual studio cpp compiler 
Cpp :: cknuth hash 
Cpp :: convert ascii char value to hexadecimal c++ 
Cpp :: constrain function in arduino 
Cpp :: how to write int variable c++ 
Cpp :: even and odd in c++ 
Cpp :: how to make randomizer c++ 
Cpp :: c++ catch Unhandled exception 
Cpp :: cast cpp 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =