S
Shlomy Shivek
I couldn't find implementation of Separate Chaining Hashtable in
System.Collections while the regular Hastable didn't let me insert more
than one value to a bucket.
So, I inherited the regular Hashtable with the following:
public class SeparateChainingHashTable:Hashtable
{
public SeparateChainingHashTable()
{
}
public override void Add(object key, object value)
{
if(!this.ContainsKey(key))
base.Add(key,new ArrayList());
(this[key] as ArrayList).Add(value);
}
public override bool ContainsValue(object value)
{
ArrayList alChain=this[value.GetHashCode()] as
ArrayList;
if(alChain!=null)
return
alChain.IndexOf(value)!=-1?true:false;
return false;
}
}
Does anyone think this is not good enough ?
System.Collections while the regular Hastable didn't let me insert more
than one value to a bucket.
So, I inherited the regular Hashtable with the following:
public class SeparateChainingHashTable:Hashtable
{
public SeparateChainingHashTable()
{
}
public override void Add(object key, object value)
{
if(!this.ContainsKey(key))
base.Add(key,new ArrayList());
(this[key] as ArrayList).Add(value);
}
public override bool ContainsValue(object value)
{
ArrayList alChain=this[value.GetHashCode()] as
ArrayList;
if(alChain!=null)
return
alChain.IndexOf(value)!=-1?true:false;
return false;
}
}
Does anyone think this is not good enough ?