Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

LONG/LONG ~ Key/Value ~ Hash (Class & lite obj)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • LONG/LONG ~ Key/Value ~ Hash (Class & lite obj)

    DLL: PB 4/8 OK
    DLL version uses an allocated lite obj handle (allocated UDT)
    Class: PB 5/9
    free - use at own risk
    whole Hash may be Stored/Restored ~ To/From string (persist)

    Code:
     
     
    'pbcc 5, pbwin 9
        '.........................................................................
        'LONG/LONG ~ Key/Value ~ Hash Class
        '       thanks to Paul Squires for sample hash code
        '.........................................................................
        '   whole Hash may be Stored/Restored ~ To/From string (persist)
        '.........................................................................
        '
        'use:
        'put "LLHashC_DLL-1.inc" in same folder as source code
        '#Include Once "LLHashC_DLL-1.inc"
        '
        'put "LLHashC_DLL-1.DLL" in same folder as source code
        '
        'LOCAL hash as LLHashI
        'hash = NewCom ClsId $LLHashC_GUID Lib "LLHashC_DLL-1.DLL"
        '   start using
     
    $LLHashC_GUID = Guid$("{9D50D3BB-DAED-4B7D-A8E2-4A42B4100983}")
    $LLHashI_GUID = Guid$("{AE0C16A0-1DEA-4D63-8725-C5770D114416}")
     
    Interface LLHashI $LLHashI_GUID
        Inherit IUnknown
        'new hash instance starts out with 100 hash slots
        '   Slots() should be set to around expected entries
        '   Slots() can be reset at any time (slow operation on big hash)
        '       if Slots() excessively < Count() then hash will be slow
        '       if Slots() excessively > Count() then memory will be wasted
     
        Method Clear()
            'delete all data
            '   call Clear() before obj = NOTHING
            '   internal resources will immediately be freed
            '       instead of waiting till obj destroyed
     
        Method Count() As Long
            'get stored Key/Value count
     
        Property Get Slots() As Long
            'get number of allocated hash slots
            '   if Slots() excessively < Count() then hash will be slow
            '   if Slots() excessively > Count() then memory will be wasted
     
        Property Set Slots(ByVal Count As Long)
            'rebuild hash to new slot count
            '   if Slots() excessively < Count() then hash will be slow
            '   if Slots() excessively > Count() then memory will be wasted
     
        Method Set(ByVal key As Long, ByVal value As Long)
            'set Value associated with Key
            'Value replaced if Key exist
     
        Method Get(ByVal key As Long) As Long
            'get Value associated with Key
     
        Method Contains(ByVal key As Long) As Long
            'True/False if Key in hash
     
        Method Delete(ByVal key As Long)
            'remove Key/Value from hash
     
        Method Store() As String
            'store hash in string
     
        Method Restore(ByVal storedHash As String)
            'restore hash from storage string
            '   current contents cleared
            '   Slots() = stored hash Count()
     
        Method StoreValidate(ByVal storedHash As String) As Long
            'True/False if string is valid
            '   storage strings protected with two unique DWord validation hashes - front/back
     
    End Interface
    Attached Files
    stanthemanstan~gmail
    Dead Theory Walking
    Range Trie Tree
    HLib ~ Free Data Container Lib ~ Arrays, Lists, Stacks, Queues, Deques, Trees, Hashes
Working...
X