HH\Lib\Keyset\union

Meta Engineer?

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

Returns a new keyset containing all of the elements of the given Traversables

namespace HH\Lib\Keyset;

function union<Tv as arraykey>(
  Traversable<Tv> $first,
  Container<Tv> ...$rest,
): keyset<Tv>;

For a variable number of Traversables, see Keyset\flatten().

Time complexity: O(n + m), where n is the size of $first and m is the combined size of all the ...$rest Space complexity: O(n + m), where n is the size of $first and m is the combined size of all the ...$rest

Parameters

Returns

  • keyset<Tv>

Examples

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

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