define vector code example
Example 1: c++ vector
#include <vector>
int main() {
std::vector<int> v;
v.push_back(10);
v.push_back(20);
v.pop_back();
v.push_back(30);
auto it = v.begin();
int x = *it;
++it;
int y = *it;
++it;
bool is_end = it == v.end();
return 0;
}
Example 2: vector
In mathematics, physics and engineering, a Euclidean vector
is a geometric object that has magnitude and direction.
Vectors can be added to other vectors according to vector algebra
Examples include:
1.)displacement
2.)velocity
3.)position
4.)force
5.)torque
Example 3: what is vector
Array based data structure
-It is synchronized - thread safe.
-It is mostly used in multi-threaded environment.
-It is much slower than ArrayList because it is
thread-safe