• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting Rid of Duplicate Objects in Vector  RSS feed

 
Tim Berett
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a large vector of java bean objects (abt 50000). The java bean consists of simple fields such as length, width, ht,... Some of the objects are duplicated (in terms of similar values of the java bean) which I need to remove.

My algorithm starts with a for loop for the original vector and a empty temp vector to store unique objects. If the object is unique, then add into the new temp vector. So for each entry in the original vector, it has to check thro all the entries in the temp vector.

I find my own algo extremely slow and stupid. Could any folks help me? Thanks!


Tim
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the java.util.HashSet class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!