I have a vector of size 20 and a second of size 5. I wish to replace elements 11-15 in the first vector with the second vector. I can do this by deleting those elements from the first vector and inserting the second vector. Is there another way to do this, perhaps by using assign?
To replace an element in Java Vector, set() method of java. util. Vector class can be used.
Is vector addition applicable to any two vectors? No, vector addition does not apply to any two vectors. Two vectors are added only when they are of the same type and nature. For instance, two velocity vectors can be added, but one velocity vector and one force vector cannot be added.
You can use std::copy
:
#include <algorithm> // for std::copy
std::copy(src.begin(), src.end(), dst.begin()+10);
where src
is the size 5 vector, and dst
is the size 20 vector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With