哈希类
哈希类
******
public class Hash
{
private Hashtable Hash_aa;
public Hash()
{
Hash_aa = new Hashtable();
}
public Hash(string CWords)
{
Hash_aa = new Hashtable();
Add_CI(CWords);
}
public void Add_CI(string CWords)
{
try
{
StreamReader sr = new StreamReader(CWords, System.Text.Encoding.Default);
string line;
while ((line = sr.ReadLine()) != null)
{
Hash_aa.Add(line, line.Length);
}
}
catch (Exception e)
{
MessageBox.Show("没有字典文件CWord.txt");
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
public void hash_cout()
{
IDictionaryEnumerator pppp = Hash_aa.GetEnumerator();
while (pppp.MoveNext())
Console.WriteLine("{0} {1}", pppp.Key, pppp.Value);
// MessageBox.Show(pppp.Key, pppp.Value);
}
public bool Find(string word)
{
return Hash_aa.ContainsKey(word);
}
}

浙公网安备 33010602011771号