Evaluate a codeblock across all items.
Syntax:
_HDICT_ITERATE_CB( pHt , codeblock , @cargo )
Parameters:
<pHt>
Handle to the hash storage
<codeblock>
The codeblock with 4 parameters and the lReturn value:
{| <pos>, <key>, <val>, <cargo>| ... , lReturn }
while evaluating, <pos>, <key>, <val> are computed from the routine.
<@cargo>
Cargo will save the values of <key>, <val> into the hashelement <pos>
The codeblock will receive 4 params nItemPosition , cKey , xValue and the provided cargo
The codeblock must return .T. to continue or .F. to stop
See the following sample:
aItems := Array( _HDICT_COUNT( pDict ) , 2 )
cbk := {|pos,key,val,cargo| cargo[pos][1] := key ,cargo[pos][2] := val, .T. }
_HDICT_ITERATE_CB( pDict, cbk , @aItems )
NOTES:
- Items inside the hash storage are sorted in random order according with the hash algorithm so
iterate the entire hash table will retrieve all items, but not the order in witch you stored the items
- Remove items inside the iteration can result into a memory exception
- Remove items inside the iteration can result into a memory exception
- Add items within the iteration can produce dupe evaluations