
scalariform.utils.Range.scala Maven / Gradle / Ivy
The newest version!
package scalariform.utils
import scala.math.Ordering
case class Range(offset: Int, length: Int) {
def contains(other: Range) = other.offset >= offset && other.offset + other.length <= offset + length
def mergeWith(other: Range) = {
val List(earliest, latest) = List(this, other) sortBy (_.offset)
Range(earliest.offset, latest.offset - earliest.offset + latest.length)
}
def isLargerThan(other: Range) = length > other.length
def intersects(other: Range) =
!(other.offset >= offset + length || other.offset + other.length - 1 < offset)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy