Remove duplicated items in an ArrayList 
Author Message
 Remove duplicated items in an ArrayList

Are there some ready-to-use code to remove duplicated items in an ArrayList?

Thanks!

--

WWW. http://www.*-*-*.com/
ICQ: 3359839
 yours Hardy



Sat, 28 May 2005 04:12:35 GMT  
 Remove duplicated items in an ArrayList
try this Hardy:

void RemoveDupes(ArrayList al) {
    for (int i = 0; i < al.Count ; i++) {
        if (
        int found = al.IndexOf(al[i], i + 1);
            if (found > i) {
                al.RemoveAt( found );
                i--;
            }
        }
    }

Quote:
}

Note that this assumes all your entries are the same type, and that there
are no null entries.


Quote:
> Are there some ready-to-use code to remove duplicated items in an
ArrayList?

> Thanks!

> --

> WWW. http://hardywang.1accesshost.com
> ICQ: 3359839
>  yours Hardy



Sat, 28 May 2005 07:55:34 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How can i have a arraylist that has items as arraylist

2. Arraylist collection without duplicates

3. program to remove the duplicates in an array

4. remove duplicates from an array of strings

5. removing exact duplicates among doubles

6. Need code to remove non-adjacent duplicate lines

7. Better way to remove duplicates?

8. list wouldnt sort and remove duplicates

9. removing duplicate values from vector

10. Remove Duplicate Strings

11. detect/remove duplicates?

12. ArrayList - unable to call the Item Property

 

 
Powered by phpBB® Forum Software