The latest thinBasic, 1.9.16.x, contains very powerful, low level hash implementation.
Here is a wrapper, which offers the following improvements:
- you can decide whether hash keys are case sensitive or not
- automatic garbage collection (no need to worry about freeing the memory)
You can download the unit from the attachement, to get idea about use, checkout this:
Uses "Console"
#INCLUDE "StringHash.tbasicu"
Dim h As stringyHash(4, FALSE)
h.SetKey("Name" , "Darth")
h.SetKey("Surname", "Vader")
PrintL "Initial key count: " + h.CountKeys
If h.hasKey("SurName") Then h.RemoveKey("SURNAME") ' -- Case insensivity allows this
PrintL "Key count after removal of one: " + h.CountKeys
PrintL h.GetKey("Name")
Dim h2 As stringyHash
h2.CloneFrom(h)
PrintL "Key count of cloned hash: " + h2.CountKeys
PrintL h2.GetKey("Name")
WaitKey
Petr
Bookmarks