Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Vectors  RSS feed

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
whippersnapper
Ranch Hand
Posts: 1843
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!