5 Replies Latest reply on Jul 29, 2008 6:19 PM by g-s-b

    Duplicate array elements

    sakura102384
      Hi everyone, I'm a newbie in flex, i would like to know is there a way on how to check for duplicate array elements?
      I will be using it to check for my forwarding module, I'm trying to filter duplicate email addresses in my email List. Is there any way i could check duplicate emails? Any feedback would be very much appreciated. Thanks in advance!
        • 1. Re: Duplicate array elements
          g-s-b Level 1
          You are going to have to write a small piece of code to do this.

          A small function to loop through the original array once whilst building a "no duplicates" array to return sounds about right.

          • 2. Re: Duplicate array elements
            Level 7

            "sakura102384" <webforumsuser@macromedia.com> wrote in message
            news:g6m17b$hc0$1@forums.macromedia.com...
            > Hi everyone, I'm a newbie in flex, i would like to know is there a way on
            > how
            > to check for duplicate array elements?
            > I will be using it to check for my forwarding module, I'm trying to filter
            > duplicate email addresses in my email List. Is there any way i could check
            > duplicate emails? Any feedback would be very much appreciated. Thanks in
            > advance!

            Look at indexOf(), every(), and some().

            HTH;

            Amy
            http://flexdiary.blogspot.com


            • 3. Duplicate array elements
              g-s-b Level 1
              Ok. So here is a simple example.
              Two arrays; one source and second destination.
              The second is generated upon the 'initialize' event of the Application tag (basically, first thing) based on a simple 'filter' function on the original array. It is always best to keep your original data in it's original form.

              • 4. Re: Duplicate array elements
                Level 7

                "g-s-b" <webforumsuser@macromedia.com> wrote in message
                news:g6nhg9$92m$1@forums.macromedia.com...
                > Ok. So here is a simple example.
                > Two arrays; one source and second destination.
                > The second is generated upon the 'initialize' event of the Application tag
                > (basically, first thing) based on a simple 'filter' function on the
                > original
                > array. It is always best to keep your original data in it's original
                > form.

                I thought the goal was to identify if there was a duplicate in the list for
                one that you were about to add, not removing duplicates that were already in
                there.

                If you're going to use a filterFunction, it's probably best to just go with
                ArrayCollection, since then you would only need the one variable.

                HTH;

                Amy


                • 5. Re: Duplicate array elements
                  g-s-b Level 1
                  Myself, I typically would use an XMLListCollections but the OP wanted an Array. Perhaps I did read it wrong for I was thinking "bulk mailing list"... oh well.