• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 954
  • Last Modified:

Most efficient way of merging 2 ArrayCollections

As the title suggest I'm looking for the fastest, cleanest most efficient way of merging 2 ArrayCollections.  I've seen several solutions on the internet but its not clear which is the best method.

Thanks.
0
RenAndStimpy
Asked:
RenAndStimpy
  • 2
  • 2
2 Solutions
 
Pravin AsarPrincipal Systems EngineerCommented:
This is a very vague description of the problem.

Can you be little more specific.

Are you looking to elliminate duplicates ? or looking to merge two distinct collections into one consolidated collection. Is the data/array collection hierarchical ?
0
 
RenAndStimpyAuthor Commented:
Apologies if the question is vague.

It will be two distinct collections consolidated into one.  The collections are  also hierarchical.

I have since gone with the following solution which seems to consolidate the collections into one, however only the results from one collection is displaying in my advanced datagrid, but thats a whole other question.

My question for now is this the best way consolidate these two distinct collections?

protected function resultGetQuotationAccessories(event:ResultEvent):void
{
    var arrAccessories:ArrayCollection = new ArrayCollection();
    arrAccessories = event.result as ArrayCollection;				
    
    arrMaterialList.source = arrMaterialList.source.concat(arrAccessories.source);
    arrMaterialList.refresh();
} 

Open in new window

0
 
Pravin AsarPrincipal Systems EngineerCommented:
If the both array collection have same (similar array structure),  your posted code could work.

But if the arrays has different structure, then you have to do little hard way.

See the example solution at:

http://stackoverflow.com/questions/7671580/merge-two-arraycollection-flex
0
 
RenAndStimpyAuthor Commented:
My posted example works well.
0
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now