In this C++ tutorial, we will go through some of the most used Vector Operations with examples.
C++ Vector Operations
Vectors are containers that can store elements in order, and can change in size.
We can perform operations on C++ Vector, like CRUD operations, conversions from vector to other datatypes or vice versa, etc.
Create
The following list of tutorials cover scenarios of how to create a vector.
Access
We can access the elements of a vector. The following tutorials show how to access elements using an index, or iterate in a loop, etc.
Checks
The following tutorials cover different checks that we can make on a vector.
Update or Transform
The following tutorials cover update or remove operations at element level on a vector.
- C++ Add element(s) to vector
- C++ Append element to the end of vector
- C++ Append vector to another vector
- C++ Insert element at the beginning of vector
- C++ Remove first element from vector
- C++ Remove last element from vector
- C++ Remove element(s) at specific index(es) from vector
- C++ Remove duplicates from a vector
- C++ Remove elements from a vector based on a condition
- C++ Resize vector
- C++ Swap elements of two vectors
- C++ Remove all elements from vector
- C++ Reverse a vector
- C++ Sort a vector
Conversions
The following tutorials cover conversions from vector to other types, and from other types to vector.
Vector Programs
- C++ Filter even numbers in an integer vector
- C++ Filter odd numbers in an integer vector
- C++ Get unique elements of a vector
- C++ Remove empty string elements from a string vector
- C++ Sort integer vector in ascending order
- C++ Sort integer vector in descending order
- C++ Sort string vector based on length
- C++ Sort string vector lexicographically
- C++ Split vector into two equal halves
Conclusion
In this C++ Tutorial, we have gone through Vector Operations, with detailed tutorials.