Hardi Table Collection Type [MSDN]

zhaozj2021-02-16  69

Hach table collection type

The HashTable class is based on the iDictionary interface, so each element in the collection is the key and value pair.

HashTable consists of a storage bucket containing a set element. The bucket is a virtual subgroup of each element in HashTable, which is simpler and faster than the search and retrieval in most collections. Each bucket is associated with a hash code, the hash code is the key generated by the hash function and based on the element.

The hash function is based on the algorithm for returning a value hash code. The key is the value of a certain property of the object being stored. The hash function must always return the same hash code for the same key. A hash function can generate the same hash code for two different keys, but when retrieving elements from the hash table, generate a sole function for each unique button will make performance better.

Each object used as an element in HashTable must be able to generate a hash code for itself using the implementation of the Object.gethashcode method. However, you can also specify a hash function by using the HashTable constructor (this constructor is accepted as one of its parameters).

When an object is added to the HashTable, it is stored in the bucket, the bucket associated with the hash code that matches the hash code of the object. When a value is searched in the HashTable, the hash code is generated for this value, and the storage bucket associated with the hash code is searched.

For example, a string has a hash ASCII code in this string and adds them together to generate a hash code. String "Picnic" will have a hash code with the hash code with the string "Basket"; therefore, the string "Picnic" and "Basket" will be in different buckets. Compared with it, "Stressed" and "Desserts" will have the same hash code and will be in the same bucket.

转载请注明原文地址:https://www.9cbs.com/read-15838.html

New Post(0)