S
shoa
Hello
I have a vector A that stores "a" objects and a vector B that stores "b"
objects. Both object "a" and "b" have one similar field "id".
Now I have to create a function to select all objects in Vector B that have
different "id" compare with objects in vector A and then do something with
them.
For example:
Vector A: have 3 objects
a1 (id=10)
a2 (id=13)
a3 (id =14)
Vector B: have 4 objects
b1 (id=10)
b2 (id =12)
b3 (id=14)
b4 (id=16)
My function will first find out object b2 and b4 (in vector B) that are not
in vector A. Then with object b2 and b4, I have to do something (update
these objects)
In my solution, I have to use two loops "for" to find objects (b2 and b4)
then have a third vector to store (object b3 and b4 as above). Then I have
to loop (go through each object) in this third vector to update these
objects.
However, if there are many objects in Vector A nd B, it is long time to do.
Do you have a better way, please let me know
Thank you
S.Hoa
I have a vector A that stores "a" objects and a vector B that stores "b"
objects. Both object "a" and "b" have one similar field "id".
Now I have to create a function to select all objects in Vector B that have
different "id" compare with objects in vector A and then do something with
them.
For example:
Vector A: have 3 objects
a1 (id=10)
a2 (id=13)
a3 (id =14)
Vector B: have 4 objects
b1 (id=10)
b2 (id =12)
b3 (id=14)
b4 (id=16)
My function will first find out object b2 and b4 (in vector B) that are not
in vector A. Then with object b2 and b4, I have to do something (update
these objects)
In my solution, I have to use two loops "for" to find objects (b2 and b4)
then have a third vector to store (object b3 and b4 as above). Then I have
to loop (go through each object) in this third vector to update these
objects.
However, if there are many objects in Vector A nd B, it is long time to do.
Do you have a better way, please let me know
Thank you
S.Hoa