HashTable

A HashTable is a collection of key-value pairs implemented using a hash table algorithm.

Namespace : System.collections

Implementing Interfaces : ICollection,IDictionary

Characteristics:

i) Search is very fast.

ii) HashTables are big and fast.

iii) High Memory Usage.

iv) Type of Access is using the hash of a key value.

 

Example.

Module ModuleHashtable

          Sub main()

                  dim ht as New Hashtable

                   ht.Add("a","aaaa") ''add(key,value)

                   ht.Add("b","bbbb")

                   ht.Add("c","cccc")

                   ht.Add("d","dddd")

                   ht.Remove("a")

                   Dim ee As IEnumerator=ht.keys.GetEnumerator()

                   While ee.MoveNext

                                Console.WriteLine(ee.Current)

                   End While

                   Console.WriteLine("test="+ht.item("a))

                   Dim en as IDictionaryEnumerator=ht.GetEnumerator()

                   While en.MoveNext

                                    Console.WriteLine(en.key+"--"+en.value)

                   End while

                   Console.ReadLine()

                   ''ht.clear()

                   ''ht.contains(key)

                    ''ht.Containskey(key)

                    ''ht.ContainsValue(value)

                    ''ht.count

                     ''ht.Keys Key collection

                    ''ht.keys Key Collection 

                    ''ht.Values Value collection

           End Sub

End Module


Average Rating (0)
by Hemdeep   Gamit  in VB.Net  on 3/24/2015 1:47:17 AM  


Post Your Comment
*