Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: JAVA indexOf() method

  1. Apr 30, 2006 #1


    User Avatar
    Science Advisor

    In Java, I am looking for a collection that will test if a given element is in a set, using the equal() method defined for the element. If it is in the set, I need the collection to give me the actual occurrence of the object from the set. Vector will do this for me via the indexOf() method, but the problem is that the search function in Vector is too slow. TreeSet will do the test for elementhood but won't retrieve the object. I also need to add additional objects to this set fairly regularly (a few tens of thousands of objects). I don't think the Java API has anything that does exactly what I want, but maybe there is another API that does? I'd rather not implement it myself.
    Last edited: Apr 30, 2006
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted