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

1 version(showEntries) dbg();
2 
3 import std.typecons : Nullable;
4 import nxt.digestx.fnv : FNV;
5 import nxt.array_help : s;
6 
7 alias K = Nullable!(uint, uint.max);
8 alias X = OpenHashSet!(K, FNV!(64, true));
9 
10 auto x = X.withElements([K(12), K(13)].s);
11 auto y = X.withElements([K(10), K(12), K(13), K(15)].s);
12 y.intersectWith(x);
13 assert(y.length == 2);
14 assert(y.contains(K(12)));
15 assert(y.containsUsingLinearSearch(K(12)));
16 assert(y.contains(K(13)));
17 assert(y.containsUsingLinearSearch(K(13)));

Meta