How to combine 3 vector into 1 Vector

I have 3 vectors
VectorA ("a","b","c")
VectorB ("d","e","f")
VectorC ("g","h","i")
I want to use VectorD to contains all the data from VectorA, VectorB, VectorC
so VectorD will contains
("a","b","c","d","e","f","g","h","i")
How to do it?


(I cannot simply do a
VectorD.add(VectorA)
VectorD.add(VectorB)
VectorD.add(VectorC)
Since then it will contains
(VectorA,VectorB,VectorC)

Also, loop through VectorA, VectorB, VectorC to dump all the data to Vector is a workable way, however in reality, each vector may contain hundred of data, and there are 60 over those vectors and performance is a concern.

So, hopefully there is a way to do it without affecting performance too much)
LVL 9
william007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
a.addAll(b);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
In your case,

VectorD.addAll(VectorA);
VectorD.addAll(VectorB);
VectorD.addAll(VectorC);
0
Mayank SAssociate Director - Product EngineeringCommented:
>> however in reality, each vector may contain hundred of data, and there are 60 over those vectors and performance is a concern

Internally, that's what addAll () will also do, I don't think there is an escape from that.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
as CHEJ said addAll will do the job.

And when it comes to performance if the program which you are writing doesn't use threads i would Suggest you to go with ArrayList then vetors (but they are not thread safe yet have better performance).Check out

http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.html
0
CEHJCommented:
If you want to get the best performance try FastList:

http://javolution.org/
0
objectsCommented:
> Also, loop through VectorA, VectorB, VectorC to dump all the data to Vector is a workable way

Thats exactly what addAll() will do :)
0
Mayank SAssociate Director - Product EngineeringCommented:
>> http://javolution.org/

Interesting :) have you used it CEHJ?
0
CEHJCommented:
>>Interesting :) have you used it CEHJ?

Yes, if only 'because it's there' in software i'm using anyway
0
william007Author Commented:
Thanks:-)
0
CEHJCommented:
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.