TextRange.intersects

struct TextRange
bool
intersects
(
const TextRange b
)

Return Value

Type: bool

true if text range a and b intersect with at least one character. This function is commutative (a·b == b·a)

Examples

bool test(TextRange a, TextRange b)
{
	bool res = a.intersects(b);
	// test commutativity
	assert(res == b.intersects(a));
	return res;
}

assert(test(TextRange(10, 4, 20, 3), TextRange(20, 2, 30, 1)));
assert(!test(TextRange(10, 4, 20, 3), TextRange(20, 3, 30, 1)));
assert(test(TextRange(10, 4, 20, 3), TextRange(12, 3, 14, 1)));
assert(!test(TextRange(10, 4, 20, 3), TextRange(9, 3, 10, 4)));
assert(test(TextRange(10, 4, 20, 3), TextRange(9, 3, 10, 5)));
assert(test(TextRange(10, 4, 20, 3), TextRange(10, 4, 20, 3)));
assert(test(TextRange(0, 0, 0, 1), TextRange(0, 0, uint.max, uint.max)));
assert(!test(TextRange(0, 0, 0, 1), TextRange(uint.max, uint.max, uint.max, uint.max)));

Meta