Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ vector operations

vector<int> v; // new empty vector
vector<int> v(5); // new vector of size 5
vector<boolean> v(5, true); // new vector of size 5 with all values initialized to true

v.size(); // get size
v[i]; // access ith element

v.push_back(x); // insert x at end of vector
v.pop_back(x); // delete last element

v.begin(); // get iterator to beginning
v.end(); // get iterator to end (theoretically, the element after the last element)

v.erase(v.begin() + 4); //delete 4th element

sort(v.begin(), v.end()) //sort vector
reverse(v.begin(), v.end()) // reverse the vector
Comment

PREVIOUS NEXT
Code Example
Cpp :: vector size c++ 
Cpp :: memset c++ 
Cpp :: how to set arrays as function parameters in c++ 
Cpp :: min heap 
Cpp :: file streams in c++ 
Cpp :: error in c++ 
Cpp :: ? c++ 
Cpp :: auto in cpp 
Cpp :: . The cout with the insertion operator (<<) is used to print a statement 
Cpp :: ue4 endoverlap c++ 
Cpp :: array bubble sort c++ static 
Cpp :: recuva recovery software for pc with crack 
Cpp :: vector insert to end 
Cpp :: why the << operator is friend 
Cpp :: uint16_t in c++ 
Cpp :: full pyramid in c++ 
Cpp :: c++ camera capture 
Cpp :: the number of ones int bitset 
Cpp :: c++ restrict template types 
Cpp :: strong number in c++ 
Cpp :: reverse a stack in c++ using another stack 
Cpp :: qpushbutton clicked connect c++ 
Cpp :: c++ vector allocator example 
Cpp :: c++ int max value 
Cpp :: cpprestsdk header 
Cpp :: how to calculate 2^7 in cpp code 
Cpp :: c++ start process and get output 
Cpp :: convert c program to c ++ online 
Cpp :: do c++ ints neeed to be initlaized 
Cpp :: c++ copy with transform 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =