What Are Hashes?

A hash table (also called a hash table) is a data structure that is accessed directly according to a key value. That is, it accesses records by mapping key values to a location in the table to speed up lookups. This mapping function is called a hash function, and the array holding the records is called a hash table.

  • If the keyword is k , its value is stored in the storage location of f (k) . As a result, the searched records can be obtained directly without comparison. This correspondence relationship f is called a hash function, and the table established according to this idea is a hash table.
  • It is possible to get the same hash address for different keywords, that is, k1 k2 , and f (k1) = f (k2) . This phenomenon is called collision. Keywords with the same function value are called synonyms for the hash function. In summary, according to the hash function f (k) and the method of dealing with conflicts, a set of keywords is mapped to a limited continuous address set (interval), and the "image" of the keywords in the address set is used as a record In the storage location of a table, this kind of table is called a hash table. This mapping process is called hash table or hash, and the resulting storage location is called a hash address.
  • If for any keyword in the keyword set, the probability that the hash function maps to any address in the address set is equal, such a hash function is called a uniform hash function (Uniform Hash function). Is to make the key through the hash function to get a "random address", thereby reducing conflicts.
1.
The above is some basic prerequisite knowledge about hash and its related. So what role does he play in emule?
Everyone knows that emule is based on P2P (short for Peer-to-peer, which refers to software for peer-to-peer connection), and it uses the "multi-source file transfer protocol" (
(The famous ELFhash algorithm) [3]
  int ELFhash (char * key)
 {
 unsigned long h = 0;
 while (* key)
 {
 h = (h << 4) + * key ++;
 unsigned long g = h & 0xF0000000L;
 if (g)
 h ^ = g >> 24;
 h & = ~ g;
 }
 return h% MOD;
 } 

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?