[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 933
  • 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 AsarCommented:
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 AsarCommented:
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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