Do you want simple or fast? This is simple:
List removeDups(List aList) {
return new ArrayList( new HashSet( aList ) );
}
Assuming "replaying" means duplicates
> Do you want simple or fast? This is simple:
> [code]
> List removeDups(List aList) {
>return new ArrayList( new HashSet( aList ) );
> code]
> Assuming "replaying" means duplicates
Odds are this will be more than fast enough anyway. Don't go looking for anything more exotic unless you measure and determine for sure that this is an unacceptable bottleneck.
Also, make sure you override equals and hashCode properly.
http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf
You may want to use a LinkedHashSet rather then a HashSet i you wish to maintain order in the approach given above.
But you are probably better off using a TreeSet rather then a list if order is important. (rather then oing though the conversion just don't put duplicates in the data structure in the first place)
matfud