intersectWith

@safe
intersectWith
(
C1
C2
)
(
ref C1 x
,
auto ref const(C2) y
)
if (
is(C1 == HybridHashMap!(_1),
_1
) &&
is(C2 == HybridHashMap!(_2),
_2
)
)

Return Value

Type: auto

x eagerly intersected with y. TODO: move to container/common.d.

Examples

r-value and l-value intersection

import std.typecons : Nullable;
import nxt.digest.fnv : FNV;
import nxt.array_help : s;

alias K = Nullable!(uint, uint.max);
alias X = HybridHashSet!(K, FNV!(64, true));

auto x = X.withElements([K(12), K(13)].s);
auto y = X.withElements([K(10), K(12), K(13), K(15)].s);
y.intersectWith(x);
assert(y.length == 2);
assert(y.contains(K(12)));
assert(y.containsUsingLinearSearch(K(12)));
assert(y.contains(K(13)));
assert(y.containsUsingLinearSearch(K(13)));

Meta