Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Dictionary example

  1. #11
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Dictionary example

    Ken, Petr,

    it is programmer responsability to know the number of keys he/she needs to store.
    In help file I mentioned to create a Dictionary with a number of slots about the double of the keys you need to store.
    This not because the key/data is a pair system but to avoid as much as possible repeating HASH values calculation inside Dictionary.

    If you read http://en.wikipedia.org/wiki/Hash_table you will see how a hash table is built.
    Dictionary_Create(MaxSlots) creates an in memory structure with the indicated free hash slots.
    When you add a new key, the Dictionary:
    • calculates the hash value (a number between 1 and MaxSlots), let say n
    • see if slot at that position n is free
    • if slot is free, key/data is stored directly
    • if slot is not free, a local linked list is created. This linked list will contain all the keys that produced the same hash value

    As you can see, the more slots, the less the possibility to create duplicated hash values, the more the speed because to find the key it is needed just one step while finding a key that produced duplicates more steps will be needed.

    I know, it is not so easy, but really, try to read http://en.wikipedia.org/wiki/Hash_table It is very interesting.
    Let me know if you need other info.
    Ciao
    Eros
    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

  2. #12
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Dictionary example

    Will read thanks for the links Eros.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  3. #13
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Dictionary example

    Eros,

    thanks a lot for the info!


    Bye,
    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

Page 2 of 2 FirstFirst 12

Similar Threads

  1. The Skeptics Dictionary
    By Charles Pegge in forum Shout Box Area
    Replies: 0
    Last Post: 12-07-2011, 00:14
  2. Dictionary speed example
    By ErosOlmi in forum Dictionary module
    Replies: 10
    Last Post: 22-04-2007, 22:48

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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