HH\Lib\Dict\count_values

Requires the Hack Standard Library to be installed.
Facebook Engineer?

This function is available as Dict\count_values() in Facebook's www repository.

Returns a new dict mapping each value to the number of times it appears in the given Traversable

namespace HH\Lib\Dict;

function count_values<Tv as arraykey>(
  Traversable<Tv> $values,
): dict<Tv, int>;

Time complexity: O(n) Space complexity: O(n)

Parameters

Returns

  • dict<Tv, int>