mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Simplify Range::encloses with Range::startsWithin && Range::endsWithin
This commit is contained in:
parent
1a54bb5c37
commit
6f79313519
1 changed files with 1 additions and 28 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue