Default initial capacity of hashtable
What is the default initial capacity of a hashtable? How can I get the capacity and load factor of hash table?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Feb 27, 2011, 12:06 PM
Soft CornerPosted Feb 24, 2011, 5:37 AM
The data type of Hashtable is object and the default size of a Hashtable is 0.
Hashtable h = new Hashtable( 149 /* capacity */, 0.75f /* loadfactor */ );
This constructor creates a Hashtable with the given capacity and load factor.
The initial capacity is not the number of elements you plan to put in the table. If you specified a capacity of 101 and a load factor of .75f, then the initial table could hold only 75 elements, before it had to grow. This means you must specify plenty of slop in your capacity setting. If you used a load factor of 1.0, your performance would be slow because you would have many collisions rather than direct lookups.
Suthish NairPosted Feb 24, 2011, 5:33 AM
Default initial capacity of a hashtable is zero.
Default load factor of a hashtable is 1.0.
Do an msdn search for more informations.