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

remove

open fun remove(element: ClosedRange<T>): Boolean (source)

Removes a range of values from the set; subtraction set logic.

Examples:

assert(IntRangeSet(listOf(5..21)).apply { remove(7..15) }.toList() == listOf(5..6, 16..21))
assert(IntRangeSet(listOf(5..9, 13..21)).apply { remove(7..15) }.toList() == listOf(5..6, 16..21))
assert(IntRangeSet(listOf(5..9, 13..21)).apply { remove(3..28) }.isEmpty())


Parameters

element - range of values to remove

Return
whether any values were removed