HH\Lib\Vec\unique_by
Returns a new vec containing each element of the given Traversable exactly once, where uniqueness is determined by calling the given scalar function on the values
namespace HH\Lib\Vec;
function unique_by<Tv, Ts as arraykey>(
Traversable<Tv> $traversable,
(function(Tv): Ts) $scalar_func,
): vec<Tv>;
In case of duplicate scalar keys, later values will overwrite previous ones.
For arraykey elements, see Vec\unique()
.
Time complexity: O(n * s), where s is the complexity of $scalar_func
Space complexity: O(n)
Parameters
Traversable<Tv>
$traversable
(function(Tv): Ts) $scalar_func
Returns
vec<Tv>