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
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
More information about thinBasic implementation of Hash Tables: http://www.thinbasic.com/public/prod...hash_table.htm
Hash Tables, or Associative Arrays, are very efficient and ultra fast data structures able to store key/data pairs. More infor at https://en.wikipedia.org/wiki/Hash_table
Their internal implementation is quite complex but their usage if very easy and straight.
To create, store, retrieve, big amount of data you just need a double word variable store anywhere.
Every key/data can store big amount of memory handled as simple dynamic strings.
Examples can be found in thinBasic installation path at \thinBasic\SampleScripts\DataStructures\
As usual Petr find more advanced ways to use thinBasic power
Last edited by ErosOlmi; 07-06-2016 at 22:27.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks