Region.opBinary

Computes the intersection of the two regions.

  1. Region opBinary(in Region other)
  2. Region opBinary(in TaggedInterval other)
  3. Region opBinary(in Region other)
  4. Region opBinary(in TaggedInterval other)
    struct Region(Number, Tag, string tagAlias = null, Tag emptyTag = Tag.init)
    opBinary
    const
    (
    string op
    )
    if (
    op == "&"
    )

Examples

1 alias R = Region!(int, int);
2 alias TI = R.TaggedInterval;
3 
4 assert((R(0, 10, 20) & R(0, 0, 5)) == R([]));
5 assert((R(0, 10, 20) & R(0, 5, 15)) == R(0, 10, 15));
6 assert((R(0, 10, 20) & R(0, 12, 18)) == R(0, 12, 18));
7 assert((R(0, 10, 20) & R(0, 10, 20)) == R(0, 10, 20));
8 assert((R(0, 10, 20) & R(0, 15, 25)) == R(0, 15, 20));
9 assert((R(0, 10, 20) & R(0, 25, 30)) == R([]));
10 assert((R(0, 10, 20) & R(1, 25, 30)) == R([]));
11 // R1:       [-------)   [-------)   [-------)
12 // R2:             [-------)   [-------)   [-------)
13 // R1 & R2:        [-)   [-)   [-)   [-)   [-)
14 assert((R([
15     TI(0, 0, 30),
16     TI(0, 40, 70),
17     TI(0, 80, 110),
18 ]) & R([
19     TI(0, 20, 50),
20     TI(0, 60, 90),
21     TI(0, 100, 130),
22 ])) == R([
23     TI(0, 20, 30),
24     TI(0, 40, 50),
25     TI(0, 60, 70),
26     TI(0, 80, 90),
27     TI(0, 100, 110),
28 ]));

Meta