Hash Table Functions:
_HDICT_NEW() -> pHt - Create a new hash table and return the handle
_HDICT_KEY_COMPARE(key1,key2) -> lEqual - Compare 2 keys (num,char or date) and return .T. if are equivalents
_HDICT_DESTROY(pHt) - Release memory used to store the hash table.
_HDICT_SETPROP(pHt,key,val) - Add new entry to the hash table and discard previous if any.
_HDICT_GETPROP(pHt,key) - Retrieve a value or NIL if entry not exist.
_HDICT_REMOVEPROP(pHt,key) - Remove a entry if exist
_HDICT_REMOVEALL(pHt) - Remove all entries
_HDICT_COUNT(pHt) - Count existing entries in the hash table
_HDICT_ITERATE_STEP(pHt,@pIterator,@item,@key)- Return 1 item at time from the hash table storage
_HDICT_ITERATE_CB( pHt , codeblock , @cargo ) - Evaluate a codeblock across all items
You have to pay attention on some special explanations on those functions on there own site:
_HDICT_ITERATE_STEP()
_HDICT_ITERATE_CB()
_HDICT_* functions and multi-thread
_HDICT_* functions don't provide built in multithread serialization !
But your classes can provide the required multithread support in a easy manner just using SYNC methods
Example:
CLASS Dictionary
EXPORTED:
VAR ht
INLINE METHOD init() ;
::ht := _HDICT_NEW() ;
return Self
INLINE SYNC METHOD Destroy() ;
_HDICT_DESTROY(::ht) ;
::ht := NIL ;
return Self
INLINE SYNC METHOD Put(key,val);
return _HDICT_SETPROP(::ht,key,val)
INLINE SYNC METHOD Get(key) ;
return _HDICT_GETPROP(::ht,key)
INLINE SYNC METHOD Del(key) ;
return _HDICT_REMOVEPROP(::ht,key)
INLINE SYNC METHOD Zap() ;
return _HDICT_REMOVEALL(::ht)
ENDCLASS