kotlin-range-sets / com.github.jonpeterson.kotlin.ranges / RangeSet / difference

difference

fun difference(element: ClosedRange<T>): RangeSet<T> (source)

Creates a new RangeSet containing values not present in this set within the specified range.

Examples:

assert(IntRangeSet(listOf(3..7, 12..16, 22..27, 29..32)).difference(5..20).toList() == listOf(8..11, 17..20)
assert(IntRangeSet(listOf(3..7, 12..16, 22..27, 29..32)).difference(1..35).toList() == listOf(1..2, 8..11, 17..21, 28..28, 33..35)


Return
new set containing values not present in this set within the specified range