The hash table is a better algorithm for quick search. The hash function in the hash table is important. The hash functions used by Java are described as follows:
/**
* Returns a hash code for this string. The hash code for
* <Code> string </code> object is computed
* <BLOCKQUOTE> <PRE>
* S [0] * 31 ^ (n-1) + s [1] * 31 ^ (n-2) +... + s [n-1]
* </PRE> </BLOCKQUOTE>
* Using <code> int </code> arithmetic, where <code> S [I] </code> is
* <I> I </I> TH character of the string, <code> n </code> is the length
* The string, and <code >^</code> indicates exponentiation.
* (The hash value of the empty string is zero .)
*
* @ Return a hash code value for this object.
*/
Public int hashcode (){
Int H = hash;
If (H = 0 ){
Int off = offset;
Char Val [] = value;
Int Len = count;
For (INT I = 0; I <Len; I ++ ){
H = 31 * H + val [Off ++];
}
Hash = h;
}
Return h;
}
Because it is a hash function, conflicts are inevitable. For example, the following Chinese characters may share the same hash value:
The Java hash values are the same as follows:
Ancient Chinese:
The word frequency table of the Chinese National Learning Bao dian (from 1 billion punctuation statistics, the simplified Chinese Word Table is temporarily released) 1.0 [] [Top 10 thousand]
The Chinese learning database is currently the largest full-text database of ancient books. It is hoped that statistics based on this database will be useful to friends who are engaged in Linguistics and search engines.
Http://www.gxbd.com
Http://bbs.guoxue.com [get updates]
Hash Value
60774744 loss
Tomo-629648662
Tokyo fork 1835901360
In addition, there are also a lot of modern Chinese, such
Settlement fines
There are still many problems with hash tables.