This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HashTable Issue....  RSS feed

 
senthil nathan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have taken a new project which has its framework already done, it uses hashtable extensively...my guess is it will affect performance...if someone can give me the clear explanation of how it will affect and if i can see some material regarding this it will be useful for me to proceed from there on...
As testing is scheduled in a month or so before that i can clean it up..to support my argument i need this..
Thanks.
Senthil
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by senthil nathan:
I have taken a new project which has its framework already done, it uses hashtable extensively...my guess is it will affect performance...

Well of course, hashtables will affect performance very much... as will Strings, Vectors, ints, classes, JDBC connections, etc. I assume you want to know how it will affect performance. :-)
Hashtables have the property of being O(1) for insertion and retrieval. This generally makes them quick. The drawbacks are 1) you can't easily sort them using the hashtable itself, and 2) that even though it's O(1), it uses a fairly expensive formula in many cases.
You'll have to either check with your JRE provider, or run your own tests to determine how fast the particular implamentation is.
--Mark
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a note that HashTable is being phased out of the jdk as is Vector.
"Completeness requires that we mention Hashtable. As with Vector and ArrayList, if you need synchronization, a Hashtable will be slightly faster than a HashMap synchronized with Collections.synchronizedMap. Again, Hashtable has loads of legacy operations, so be extra careful always to manipulate it with the Map interface, or you'll be stuck with it for life. "
from The Java Tutorial - Trail: Collections
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using Java 1.4, Hashtable seems to be faster than HashMap, oddly enough. I still haven't heard from Sun about the bug report I filed though.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!