Region.TaggedInterval

This is a right-open interval [begin, end) tagged with tag. If tagAlias is given then the tag may be access as a property of that name.

Members

Functions

intersects
bool intersects(in TaggedInterval other)

Returns true iff the tagged intervals intersect.

isStrictlyAfter
bool isStrictlyAfter(in TaggedInterval other)

Returns true iff the tagged intervals do not intersect and this > other.

isStrictlyBefore
bool isStrictlyBefore(in TaggedInterval other)

Returns true iff the tagged intervals do not intersect and this < other.

opBinary
TaggedInterval opBinary(in TaggedInterval other)

Returns the intersection of both intervals; empty if tags differ.

opBinary
Region opBinary(in TaggedInterval other)

Returns the difference of both intervals.

opBinary
bool opBinary(in TaggedInterval other)

Returns true iff this is a subset of other, ie. fully included _in_.

opOpAssign
TaggedInterval opOpAssign(in TaggedInterval other)

Returns the intersection of both intervals; empty if tags differ.

Properties

empty
bool empty [@property getter]

Returns true iff the interval is empty. An interval is empty iff begin == end.

size
Number size [@property getter]

Returns the size of this interval.

Static functions

convexHull
TaggedInterval convexHull(in TaggedInterval[] intervals...)

Returns the convex hull of the intervals.

Examples

1 static enum emptyTag = 42;
2 alias R = Region!(int, int, "bucketId", emptyTag);
3 alias TI = R.TaggedInterval;
4 
5 TI emptyInterval;
6 
7 // Default constructor produces empty interval.
8 assert((emptyInterval).empty);
9 assert(emptyInterval.tag == emptyTag);
10 
11 auto ti1 = TI(1, 0, 10);
12 
13 // The tag can be aliased:
14 assert(ti1.tag == ti1.bucketId);
15 
16 auto ti2 = TI(1, 5, 15);
17 
18 // Tagged intervals with the same tag behave like regular intervals:
19 assert((ti1 & ti2) == TI(1, 5, 10));
20 
21 auto ti3 = TI(2, 0, 10);
22 
23 // Tagged intervals with different tags are distinct:
24 assert((ti1 & ti3).empty);

Meta