Purpose
The HashTable keyword class provides an extremely high performance method for storing arbitrary data values in memory for fast retrieval.
Example
Dim ht as HashTable
Dim i as Integer
Dim Items as Integer
Dim t as PerfTimer
Dim x as Integer
Items = 100000
Debug "Testing overhead to execute the loop..."
t.Start
for i = 0 to Items-1
x = x + 1
next i
Debug "Overhead test took " & t.ElapsedMS & "ms" & fcCRLF
Debug "Adding " & items & " items..."
t.Start
for i = 0 to Items-1
ht.Add("Test " & i,i)
next i
Debug "Adding " & ht.NumItems & " took " & t.ElapsedMS & "ms" & fcCRLF
Debug "Item 5 is " & ht.Find(5)
Debug "Finding all items in reverse..."
t.Start
for i = Items-1 to 0 step -1
ht.Find(i)
next i
Debug "Finding " & ht.NumItems & " took " & t.ElapsedMS & "ms" & fcCRLF
Debug "Deleting an item..."
ht.Remove(3)
Debug "Items remaining: " & ht.NumItems & fcCRLF
Debug "Replace all items in reverse..."
t.Start
for i = Items-1 to 0 step -1
ht.Replace("Replace Test " & i,i)
next i
Debug "Replacing " & ht.NumItems & " took " & t.ElapsedMS & "ms" & fcCRLF
Debug "Resetting tables..."
ht.Reset
Debug "Items remaining: " & ht.NumItems & fcCRLF
|