Hi,
A Hashtable is the most efficient form of retrieval structure as long as
you have an efficient hash algorithm (seeded random number generator).
and the performance degradation with volume is negligible so long as the
system is using some form of extendable hashing.
Look up info on extensible hashing to see how it all works.
An example link is here:
http://feast.ucsd.edu/CSE232W99/Indexing/sld034.htm
although the 'good' hash algorithm he suggests is a poor one :)
The GetHashCode() in .Net uses a version of the Zobel/Ramakrishna algorithm
(the best performing algorithm I'm aware of) but has been adapted to
produce a guaranteed unique key (not necessary for a hash table but
sometimes required internally by .Net).
If you want to 'roll your own' for some obscure data structure then I've
attached an adaptation of the hash function below.
Cheers,
Jason
Public Function computeHashCode (ByVal StrToHash As String) As Integer
Dim c As Byte() =
System.Text.Enc oding.UTF8().Ge tBytes(StrToHas h.ToCharArray() )
Dim h As Integer = 31 'seed chosen at random
Dim i As Integer
For i = 0 To c.Length - 1
' L=5, R=2 works well for ASCII input
h = (h Xor ((h * 32) + (h \ 4) + c(i))) And &HFFFF
Next
Return h
End Function
On Tue, 27 Jan 2004 09:48:26 +1300, Greg Bacchus wrote:
Hi,
I'm just concerned about storing a large amount of items in a Hashtable. It
seems to me that as the number of keys in the Hashtable increases, so does
the chance of key clashes.
Does anyone know about the performance with regards to this?
Cheers
Greg