arrays

Discussion in 'ASP General' started by Mike P, Aug 8, 2008.

  1. Mike P

    Mike P Guest

    I have a collection of objects that may have duplicates in it. What I
    want to do is to iterate through the list and only add the non
    duplicates to an array, so as I am adding to the array, I need some way
    of checking against the current contents of the array. Is this
    possible, or is there a better way to do this?



    *** Sent via Developersdex http://www.developersdex.com ***
    Mike P, Aug 8, 2008
    #1
    1. Advertising

  2. Mike P wrote:
    > I have a collection of objects that may have duplicates in it. What I
    > want to do is to iterate through the list and only add the non
    > duplicates to an array, so as I am adding to the array, I need some
    > way of checking against the current contents of the array. Is this
    > possible, or is there a better way to do this?
    >
    >
    >

    There's no shortcut. You need to do a nested loop.


    start loop through collection
    within the collection loop, loop through the array checking to see if object
    already exists.
    if not, add the object to the array and move to the next object

    Do you need more detail than that? if so, we sill need more details.

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Aug 8, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandra Stehman
    Replies:
    5
    Views:
    30,537
    Chris Smith
    Jun 17, 2004
  2. Bill Reyn
    Replies:
    3
    Views:
    2,231
    Bob Hairgrove
    Jun 22, 2004
  3. Mantorok Redgormor

    initializing arrays of arrays

    Mantorok Redgormor, Sep 10, 2003, in forum: C Programming
    Replies:
    4
    Views:
    552
  4. kelvSYC

    Arrays and Pointers to Arrays

    kelvSYC, Sep 26, 2003, in forum: C Programming
    Replies:
    2
    Views:
    374
  5. Philipp
    Replies:
    21
    Views:
    1,109
    Philipp
    Jan 20, 2009
Loading...

Share This Page