Results 1 to 3 of 3
Thread: Search a object in a vector
- 04-30-2008, 01:16 PM #1Member
- Join Date
- Mar 2008
- Rep Power
Search a object in a vector
I am supposed to see whether an object of a class (not Object class) is already in vector containing some objects of same class.
I have a class "Edge" having a sourceNode and targetNode.
I am storing the instances of this class in an vector but before storing I need to know whether the new instance already exists in the vector or not?(edge with same source and target node)
Can anyone let me know how can i do it?
- 04-30-2008, 02:42 PM #2
You can use contains(Object o) method to test if that is already exists....
Or you can start to read here for more understandable details,
sukatoafreedom exists in the world of ideas
- 04-30-2008, 03:05 PM #3
You can also use java.util.TreeSet<E>. It does it all at once for you :)Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- By Albert in forum Advanced JavaReplies: 2Last Post: 11-26-2010, 03:12 AM
- By bobleny in forum New To JavaReplies: 1Last Post: 04-17-2008, 11:10 PM
- By doobybug in forum New To JavaReplies: 1Last Post: 03-12-2008, 07:37 PM
- By king_arthur in forum New To JavaReplies: 3Last Post: 01-22-2008, 08:33 PM
- By venkatv in forum New To JavaReplies: 3Last Post: 07-17-2007, 04:33 PM