Results 1 to 10 of 10

Thread: Possible to "Redim" Dictionary?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    55
    Posts
    1,555
    Rep Power
    174

    Possible to "Redim" Dictionary?

    I wonder if it's possible to "redim" the dictionary if I need more keys.

    The help warns about:

    More than NumberOfKeys keys can be stored into a dictionary but this will slow down all operations.
    So I fear to reach the limit but also to use up unnecessary memory if not 5000 keys used...

    Now I thought about some "Redim Preserve" in this manner:

    Uses "Dictionary"
    Dword pDictionary = Dictionary_Create(1000)
    ' ...
    ' now discover I have reached limit, 1000 Keys are used...
    
    ' copy dictionary to some buffer
    Dword pBuffer = Heap_Alloc( Dictionary_MemInfo(pDictionary, %HT_MemInfo_Total) )
    Memory_Copy( pDictionary, pBuffer, Heap_Size(pBuffer) )
    
    'kill the old dictionary
    Dictionary_Free(pDictionary)
    
    ' create a bigger one
    pDicitonary = Dictionary_Create(2000)
    
    ' put the data back? 
    Memory_Copy( pBuffer, pDictionary, Heap_Size(pBuffer) )
    
    would this work or corrupt the dictionary-content?

    Last edited by ReneMiner; 16-05-2013 at 13:17.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. Forum: added "Auto Youtube Link-Converter" plugin
    By ErosOlmi in forum Web and Forum
    Replies: 0
    Last Post: 07-05-2011, 12:47
  2. The original "Python programming in OpenGL" by Stan Blank
    By Petr Schreiber in forum ThinBASIC programming in OpenGL/TBGL
    Replies: 0
    Last Post: 25-02-2010, 17:48
  3. Replies: 17
    Last Post: 21-02-2010, 07:45
  4. Uses "File", "Crypto" ... ???
    By marcuslee in forum thinBasic General
    Replies: 3
    Last Post: 01-12-2009, 19:38

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
  •