Most efficient way of merging 2 ArrayCollections

Posted on 2012-08-21
Last Modified: 2012-08-28
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.

Question by:RenAndStimpy
    LVL 28

    Expert Comment

    by:Pravin Asar
    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 ?

    Accepted Solution

    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);

    Open in new window

    LVL 28

    Assisted Solution

    by:Pravin Asar
    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:

    Author Closing Comment

    My posted example works well.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
    Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
    In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
    This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now