CBA_fnc_hashFilter

Description

Iterate through all keys and values in a Hash.  If function returns false, the key is removed from the hash (just like `[] select {}`)

Data passed to the function on each iteration,

  • _key - Key from the Hash.
  • _value - The value from the Hash corresponding to _key.

See CBA_fnc_hashCreate.

Parameters

_hashHash to iterate [Array which is a Hash structure]
_codeFunction to call with each pair which returns a bool (false will remove key from hash) [Code]

Returns

Number of removed entrys [Number]

Example

_hash = [[["A1", 1], ["A2", 1], ["B", 2], ["C", 3], ["D1", 4], ["D2", 4], ["E1", 5], ["E2", 5]]] call CBA_fnc_hashCreate;
_removeOddValues = {
    diag_log format ["Key: %1, Value: %2", _key, _value];
    ((_value % 2) == 0)
};
_removedCount = [_hash, _removeOddValues] call CBA_fnc_hashFilter;

Author

PabstMirror

Creates a new Hash
Close