HH\Lib\Keyset\diff
Returns a new keyset containing only the elements of the first Traversable that do not appear in any of the other ones
namespace HH\Lib\Keyset;
function diff<Tv1 as arraykey, Tv2 as arraykey>(
Traversable<Tv1> $first,
Traversable<Tv2> $second,
Container<Tv2> ...$rest,
): keyset<Tv1>;
Time complexity: O(n + m), where n is size of $first and m is the combined
size of $second plus all the ...$rest
Space complexity: O(n + m), where n is size of $first and m is the combined
size of $second plus all the ...$rest -- note that this is bigger than
O(n)
Parameters
Traversable<Tv1>$firstTraversable<Tv2>$secondContainer<Tv2>...$rest
Returns
keyset<Tv1>
Examples
$result = Keyset\diff(keyset[1,2,3,4,5,6], vec[1,2,3]);
print_r($result);
//result: keyset[4,5,6]
$result = Keyset\diff(vec[1,2,3,4,5,6], keyset[]);
print_r($result);
//result: keyset[1,2,3,4,5,6]