wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes HashTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HashTable" Watch "HashTable" New topic
Author

HashTable

Chris Linde
Greenhorn

Joined: Oct 15, 2001
Posts: 10
I am wondering what memory scheme is used to layout a Hashtable in Java. Is it the case that an array holds all the keys, and each key points to the address of it's corresponding value object which exists somewhere out there in memory? Or is it more like a two dimensional array, where each 'bucket' holds key/value pairs right next to each other? If anyone can help me understand this I would be grateful!
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
In you JDK, you may find a file src.jar, which includes sample source for much of the standard library, including Hashtable.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well, it is more like your first description.
A Hashtable is an array of Entry objects. Each Entry instance has several fields in it:
int hash;
Object key; // this refers to an entry in the KeySet
Object value; // this refers to a entry in the ValueSet
Entry next; //this refers to a entry in the EntrySet
However the Hashtable as a whole also has an Enumerator object and an Iterator object and several other tracking fields like counts and hashcodes etc.
So it gets quite compicated.

[This message has been edited by Cindy Glass (edited October 16, 2001).]


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HashTable
 
Similar Threads
hashmap and equals doubts
Hashtable / HashMap Problem.
Two dimensional data structures?
Hashtable in memory versus database table in memory
Question about clone a Hashtable