How to create and use the hash table This example explains how to create and use a hash table. The hash table is a collection composed of key-value combinations, organizations into the "storage bucket" for fast search. You can search the hash table with the key or associated value; but if the quick search is your goal, the button search is usually faster.
VB HashTable.aspx
[
Run example] | [[[[
View Source Code]
As mentioned in the introduction, the hash table is a collection. When populating a hash table, provide a key to the table to be added to the table and provide a value accompanying the key. In the example below, the employee ID number is used in the key, then the employee name to help you understand the combination type available. Note that the key is not required to be a value: Any object is acceptable.
Why is the hash table? When these keys-value pairs are added to the hash table, the hash table will look up the button and give it a hash code, this code is the number identifies the key (each button added will get a hash process. ). These hash code is then placed in "storage bucket" to help organizations. This will be helpful when trying to find in the table.
Temporarily do not need these buckets. If you want to find an element in an array, you must traverse each element of the array to find the element. You don't know where it is, so there is no quick way to search for each. Instead, the hash table can search for a specific key faster, because once it provides a button, it knows in which bucket is looking for. This means it only looks for a subset of all elements.
It is important to remember that this faster search mechanism is only available when searching by key. You can search by value, but it may be slower than the key. Therefore, the key search should be executed if possible.
To add an element to the hash table, call the Add method to pass it into the key-value pair you want to add.