My guess is that they it's scaled because it's fairly easy to tell
people that they should use a load factor between 0 and 1. If the load
factor ranged between 0 and 1 but the best value was 0.72, somebody
would pass in something like 0.90 and then have problems when their
hashtable didn't work. 

-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Scott Mitchell
Sent: Monday, September 29, 2003 10:09 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] System.Collections.Hashtable question...


Why does the Hashtable allow you to pass in a load factor of 0.1 to 1.0,
but then, regardless of the value you pass in, it scales it by 72%?  If
you look at the rotor code -
http://123aspx.com/rotor/rotorsrc.aspx?rot=40811 - or decompile the
mscorlib.dll code in Reflector you see in the constructor as (some
snippets removed for brevity):

public Hashtable(int capacity, float loadFactor, IHashCodeProvider hcp,
IComparer comparer) {

    // Based on perf work, .72 is the optimal load factor for this
table.
    this.loadFactor = 0.72f * loadFactor;

    ...
}


Why multiple by 0.72?  Ok, yes, it says best perf is 0.72, then why not
make the default loadFactor 0.72?  (The default is 1.0.)  Anyway, it is
limiting beause if someone, for some reason, does want to make the load
factor 0.9, they can't.  They can't make it anything greater than 0.72.

Does anyone know any good reason why it is this way?  I'm curious, and
would like to be able to fathom why this decision was made.

TIA

    Scott...

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com NEW!
ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to