intersectWith

@safe
intersectWith
(
C1
C2
)
(
ref C1 x
,
auto ref const(C2) y
)
if (
isInstanceOf!(OpenHashMap, C1) &&
isInstanceOf!(OpenHashMap, C2)
)

Return Value

Type: auto

x eagerly intersected with y. TODO move to container_algorithm.d.

Examples

r-value and l-value intersection

version(showEntries) dbg();

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

alias K = Nullable!(uint, uint.max);
alias X = OpenHashSet!(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