HH\Lib\Keyset\flatten

Meta Engineer?

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

Returns a new keyset formed by joining the values within the given Traversables into a keyset

namespace HH\Lib\Keyset;

function flatten<Tv as arraykey>(
  Traversable<Container<Tv>> $traversables,
): keyset<Tv>;

For a fixed number of Traversables, see Keyset\union().

Time complexity: O(n), where n is the combined size of all the $traversables Space complexity: O(n), where n is the combined size of all the $traversables

Parameters

Returns

  • keyset<Tv>

Examples

$example_set = vec[keyset[1,2,3,4,5],keyset[98, 99]];
$result = Keyset\flatten($example_set);
print_r($result);
//result: keyset[1,2,3,4,5,98,99]

$example_set = vec[vec[1,2,3,4,5,5,5,5]];
$result = Keyset\flatten($example_set);
print_r($result);
//result: keyset[1,2,3,4,5]

$example_set = vec[];
$result = Keyset\flatten($example_set);
print_r($result);
//result: keyset[]