public long this[long key]
{
get {
LongHashtableEntry[] tab = table;
int hash = key.GetHashCode();
int index = ( hash & 0x7FFFFFFF ) % tab.Length;
for ( LongHashtableEntry e = tab[index] ; e != null ; e = e.next ) {
if ( e.hash == hash && e.key == key )
return e.value;
}
return 0;
}
set {
// Makes sure the key is not already in the hashtable.
LongHashtableEntry[] tab = table;
int hash = key.GetHashCode();
int index = ( hash & 0x7FFFFFFF ) % tab.Length;
for ( LongHashtableEntry e = tab[index] ; e != null ; e = e.next ) {
if ( e.hash == hash && e.key == key ) {
e.value = value;
return;
}
}
if ( count >= threshold ) {
// Rehash the table if the threshold is exceeded.
Rehash();
this[key] = value;
return;
}
// Creates the new entry.
LongHashtableEntry en = new LongHashtableEntry();
en.hash = hash;
en.key = key;
en.value = value;
en.next = tab[index];
tab[index] = en;
++count;
}
}