Simplify Range::encloses with Range::startsWithin && Range::endsWithin

This commit is contained in:
Thomas Lauf 2018-09-18 06:57:07 +02:00
parent 1a54bb5c37
commit 6f79313519

View file

@ -148,36 +148,9 @@ bool Range::overlap (const Range& other) const
}
////////////////////////////////////////////////////////////////////////////////
// Detect the following enclosure cases:
//
// this [--------)
// C [----)
//
// this [...
// C [----)
// D [--------)
// E [--------)
// H [...
// I [...
//
bool Range::encloses (const Range& other) const
{
if (is_started ())
{
if (is_ended ())
{
if (other.is_started () && other.start >= start &&
other.is_ended () && other.end <= end)
return true;
}
else
{
if (other.is_started () && other.start >= start)
return true;
}
}
return false;
return other.startsWithin (*this) && other.endsWithin (*this);
}
////////////////////////////////////////////////////////////////////////////////