searching vectors

Hi all,

My problem is the following:

parsing a file I have to add elements to a vector only if I didn't add them before.

So I search the vector using the contains method: if it is false, I add the new element.

Unfortunately while vector is growing, the search slow down, and the code is totally unusable (we are speaking about several thousands elements)

Is there any other object rather than java.util.Vector to better do this job ? In example a sorted vector could be faster searchable, but perhaps slowly insertable..

Thanks all in advance,

Andrea

[600 byte] By [lanzaandreaa] at [2007-11-26 19:01:19]
# 1
Use a Set, it only contains unique elements (make sure the objects implement equals and hashcode properly) so you can just add everything and it'll be nice and clean.
-Kayaman-a at 2007-7-9 20:45:46 > top of Java-index,Java Essentials,Java Programming...
# 2
It seems Set is exactly what I need.Now I will search how to use this interface.Thank you
lanzaandreaa at 2007-7-9 20:45:46 > top of Java-index,Java Essentials,Java Programming...