aspose file tools*
The moose likes Beginning Java and the fly likes Vectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vectors" Watch "Vectors" New topic
Author

Vectors

Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
What is the difference between how Vector.contains() searches in the vector and how Vector.indexOff() searches in the vector?
Also which one is efficient??


The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1746
    
    2
Originally posted by Chinmay Bajikar:
What is the difference between how Vector.contains() searches in the vector and how Vector.indexOff() searches in the vector?
Also which one is efficient??

From the source code of Vector:

You can see that Vector's contains() calls its two-argument indexOf() method. (And the single-argument version of indexOf() also calls the two-argument indexOf().) So they search the same way! Can't imagine that the extra method calls of contains() or single-argument indexOf() have any (measurable) performance impact. I'd base my decision between the two on which return type I need: contains() returns a boolean and indexOf() returns an integer index.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vectors