1 Reply Latest reply on Sep 11, 2007 4:02 PM by Ansury

    XMLListCollections

    bitwyse Level 1
      I have two XMLList Collections. I would like to append the two collections. Ultimately I would love to remove any duplicates as well and have one unique list.

      Any help would be appreciated.
        • 1. XMLListCollections
          Ansury Level 3
          I don't know of any quick and easy way to do that but if they're small lists it shouldn't be hard. (If there is one I'd like to know as well...) The best strategy would probably depend on the size of the lists.

          If they're not large, just a simple for each loop, adding elements that don't already exist to one of the lists would probably be easiest.

          If they're very big, you may try searching out a hashing/HashMap type ActionScript class from the internet to use.. or write your own. I don't think that data structure exists in AS yet. But there's bound to be some class already written if you look around online for one.

          I know that in Java (and you'd have to confirm that the hashing algorithm you use behaves similarly), when you add a value to a HashMap with a key that already exists, it either overwrites the old or doesn't add the new item. (I forget which it does.) This effectively eliminates duplicates and since it's a hashing algorithm it's pretty quick for larger data sets. After that's done, if you can just get a list (as a Java HashMap allows) of all the values in the hash map, your lists are combined and duplicates are gone.