HH\Lib\Dict\flip
Requires the Hack Standard Library to be installed.
Facebook Engineer?
This function is available as Dict\flip()
in Facebook's www repository.
Returns a new dict keyed by the values of the given KeyedTraversable and vice-versa
namespace HH\Lib\Dict;
function flip<Tk, Tv as arraykey>(
KeyedTraversable<Tk, Tv> $traversable,
): dict<Tv, Tk>;
In case of duplicate values, later keys overwrite the previous ones.
Time complexity: O(n) Space complexity: O(n)
Parameters
Returns
dict<Tv, Tk>