fun retain(element: ClosedRange<T>): Boolean
(source)Removes all values from set except those contained in the specified range; intersection set logic.
Examples:
assert(IntRangeSet(listOf(5..21)).apply { retain(7..15) }.toList() == listOf(7..15))
assert(IntRangeSet(listOf(5..9, 13..21)).apply { retain(7..15) }.toList() == listOf(7..9, 13..15))
assert(IntRangeSet(listOf(5..9, 13..21)).apply { retain(2..25) }.toList() == listOf(5..9, 13..21))
element
- range of values to keepReturn
whether any values were removed