Results 1 to 2 of 2

Thread: StringyHash - easy to use hash

Share/Bookmark
  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,759
    Blog Entries
    3
    Rep Power
    688

    Lightbulb StringyHash - easy to use hash

    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
    Attached Files Attached Files
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,091
    Blog Entries
    2
    Rep Power
    10
    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/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Similar Threads

  1. tDictionary - class for easy Dictionary handling
    By ReneMiner in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 2
    Last Post: 06-05-2015, 11:42
  2. hash example
    By sandyrepope in forum thinBasic General
    Replies: 7
    Last Post: 26-07-2007, 16:10
  3. TBGL makes OpenGL so easy
    By kryton9 in forum TBGL General
    Replies: 2
    Last Post: 10-02-2007, 19:46

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •