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

addAll

open fun addAll(elements: Collection<ClosedRange<T>>): Boolean (source)

Adds ranges of values to the set; addition set logic.

Examples:

assert(IntRangeSet(listOf(5..21)).apply { addAll(listOf(7..10, 12..15)) }.toList() == listOf(5..21))
assert(IntRangeSet(listOf(5..8, 11..16)).apply { addAll(listOf(7..10, 14..20)) }.toList() == listOf(5..20))
assert(IntRangeSet(listOf(11..16)).apply { addAll(listOf(7..10, 18..21)) }.toList() == listOf(7..16, 18..21))


Parameters

elements - ranges of values to add

Return
whether any values were added