intersectionOf

Computes the intersection of setA and setB as a set operation and returns the retult in a new sorted array. Both setA and setB are required to be sorted. If either setA or setB contain duplicates, the result will contain the smaller number of duplicates from setA and setB. All entries will be copied from setA. Comparisons will be performed using the supplied predicate or '<' if none is supplied.

T[]
intersectionOf
()
(
in T[] setA
,
in T[] setB
,
Pred pred = Pred.init
)

Parameters

setA T[]

The first sorted array to evaluate.

setB T[]

The second sorted array to evaluate.

pred Pred

The evaluation predicate, which should return true if e1 is less than e2 and false if not. This predicate may be any callable type.

Return Value

Type: T[]

A new array containing the intersection of setA and setB.

Examples

test!("==")(intersectionOf( ""[], ""[] ), "");
test!("==")(intersectionOf( "abc"[], "def"[] ), "");
test!("==")(intersectionOf( "abbbcd"[], "aabdddeefg"[] ), "abd");

Meta