Meta Engineer?

This is available as Keyset\filter_with_key in the www repository.

Returns a new keyset containing only the values for which the given predicate returns true

namespace HH\Lib\Keyset;

function filter_with_key<Tk, Tv as arraykey>(
  KeyedTraversable<Tk, Tv> $traversable,
  (function(Tk, Tv): bool) $predicate,
): keyset<Tv>;

If you don't need access to the key, see Keyset\filter().

Time complexity: O(n * p), where p is the complexity of $predicate Space complexity: O(n)



  • keyset<Tv>