From 6f79313519650c674c936e79b39bcbc2808a8ff5 Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Tue, 18 Sep 2018 06:57:07 +0200 Subject: [PATCH] Simplify Range::encloses with Range::startsWithin && Range::endsWithin --- src/Range.cpp | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/Range.cpp b/src/Range.cpp index d6c21a0d..bed22d91 100644 --- a/src/Range.cpp +++ b/src/Range.cpp @@ -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); } ////////////////////////////////////////////////////////////////////////////////