HH\Lib\Dict\pull_with_key
Returns a new dict with mapped keys and values
namespace HH\Lib\Dict;
function pull_with_key<Tk1, Tk2 as arraykey, Tv1, Tv2>(
KeyedTraversable<Tk1, Tv1> $traversable,
(function(Tk1, Tv1): Tv2) $value_func,
(function(Tk1, Tv1): Tk2) $key_func,
): dict<Tk2, Tv2>;
- values are the result of calling
$value_func
on the original value/key - keys are the result of calling
$key_func
on the original value/key. In the case of duplicate keys, later values will overwrite the previous ones.
Time complexity: O(n * (f1 + f2), where f1 is the complexity of $value_func
and f2 is the complexity of $key_func
Space complexity: O(n)
Parameters
KeyedTraversable<Tk1,
Tv1> $traversable
(function(Tk1, Tv1): Tv2) $value_func
(function(Tk1, Tv1): Tk2) $key_func
Returns
dict<Tk2, Tv2>