DLL: PB 4/8 OK
DLL version uses an allocated lite obj handle (allocated UDT)

Class: PB 5/9

whole Hash may be Stored/Restored ~ To/From string (persist)

separate INC and DLL for each in zip files

free - use at own risk

Code:
 
 
'pbcc 5, pbwin 9
    '.........................................................................
    'STRING/STRING ~ Key/Value ~ Hash lite object (not OOP object)
    '       thanks to Paul Squires for sample hash code
    '   all hash procedures [SSHash_...()] require a hash handle: SSHash_Alloc()
    '   handle must be freed before it goes out of scope: SSHash_Free()
    '.........................................................................
    '   whole Hash may be Stored/Restored ~ To/From string (persist)
    '.........................................................................
 
Declare Function SSHash_Alloc Lib "SSHash_DLL-1.dll" (ByVal totalSlots As Long) As Long
    'open hash object
    'return handle
 
Declare Sub SSHash_Free Lib "SSHash_DLL-1.dll" (ByVal h As Long)
    'close hash handle
    'free resources
 
Declare Sub SSHash_Clear Lib "SSHash_DLL-1.dll" (ByVal h As Long)
    'delete all items
 
Declare Function SSHash_Count Lib "SSHash_DLL-1.dll" (ByVal h As Long) As Long
    'get stored Key/Value count
 
Declare Function SSHash_HashSlotCount Lib "SSHash_DLL-1.dll" (ByVal h As Long) As Long
    'get number of allocated hash slots
    '   if SSHash_HashSlotCount() excessively < SSHash_Count() then hash will be slow
    '   if SSHash_HashSlotCount() excessively > SSHash_Count() then memory will be wasted
 
Declare Sub SSHash_Rebuild Lib "SSHash_DLL-1.dll" (ByVal h As Long, ByVal newSlotCount As Long)
    'rebuild hash to change slot count
    '   if SSHash_HashSlotCount() excessively < SSHash_Count() then hash will be slow
    '   if SSHash_HashSlotCount() excessively > SSHash_Count() then memory will be wasted
    'good to before a lot of SSHash_Set() operations
    'good to after a lot of SSHash_Delete() operations
 
Declare Sub SSHash_Set Lib "SSHash_DLL-1.dll" (ByVal h As Long, ByRef key As String, ByRef value As String)
    'set Key/Value pair
    'Value replaced if Key exist
 
Declare Function SSHash_Get Lib "SSHash_DLL-1.dll" (ByVal h As Long, ByRef key As String) As String
    'get Value associated with Key
    '   NULL/ZERO/FALSE returned if Key doesn't exist
    '       (a Key's Value may be a NULL)
 
Declare Function SSHash_Contains Lib "SSHash_DLL-1.dll" (ByVal h As Long, ByRef key As String) As Long
    'see if Key is in hash
    '   non-zero if found (handle to List Item)
    '   False if not found
 
Declare Sub SSHash_Delete Lib "SSHash_DLL-1.dll" (ByVal h As Long, ByRef key As String)
    'remove Key/Value from hash
 
Declare Function SSHash_Store Lib "SSHash_DLL-1.dll" (ByVal h As Long) As String
    'store hash in string
 
Declare Function SSHash_StoreValidate Lib "SSHash_DLL-1.dll" (ByVal storedHash As String) As Long
    'validate storage string
    '   string has front and back DWord validation hash cookies
 
Declare Sub SSHash_Restore Lib "SSHash_DLL-1.dll" (ByVal h As Long, ByVal storedHash As String)
    'restore hash from string: SSHash_Store()
    '   current contents will be lost
    '   slot count will be set to stored count
Attached Files