C # _ Dictionary collection _Hashtable Introduction and role

Hashtable Introduction

       Hashtable represents a key / value pairs, in the Hashtable .net framework is provided a container under system.colletions namespace. For processing the key-value and the performance of similar value pairs, wherein the key is typically used to search, and is case sensitive key; value for storing a value corresponding to the key. Hashtable in keyvalue key-value pairs are object types, Hashtable can support any type of keyvalue key-value pairs, any non-null object can be used as a key or value.

        HashTable is a hash table, he maintained internally a lot of key-value pairs Key-Value, there is a similar index whose value is called the hash value (HashCode), which is based on the Key GetHashCode method through a certain algorithm to obtain get all find operation positioning operation are achieved and find the corresponding Key value value based on the hash value.

        Hash function (GetHashCode) so that the address space corresponding to the hash value will not be repeated as much as possible the HashTable.

        When a HashTable is occupied more than half the time we get an address by calculating the hash value may be repeated point to the same address, which resulted hash collision.

       C # keys right position Position in the HashTable = (HashCode & 0x7FFFFFFF)% HashTable.Length, C # is the solution to hash collisions by detecting method, when the position Postion acquired by the hash value and when occupied, will increase determining a next value of a position displacement x Postion + x is occupied, and if occupied still continues the displacement x is determined position + 2 * x down position is occupied, not occupied if the value is placed therein. When the available space HashTable more and more hours, then get more difficult to get more and more space available, the more time consuming.

Guess you like

Origin www.cnblogs.com/Roz-001/p/11018318.html