View Source RangeSet (rangeset v0.1.0)

This behaves like MapSet except you use it on lists of ranges like [1..3, 8..9].

Any functions that opperate on individual elements have not been implemented (like filter). If this is required, please explicitly call RangeSet.to_list/1.

Behaviour is undefined for ranges with steps other than 1.

Summary

Functions

Take a list of ranges and make sure that it is sorted. Any adjacent ranges are merged. Empty ranges are removed.

Functions

clean(list)

Take a list of ranges and make sure that it is sorted. Any adjacent ranges are merged. Empty ranges are removed.

assert RangeSet.clean([2..3, 10..11, 11..12, 1..2, 1..0//1]) == [1..3, 10..12]

Input and output of the other functions automatically use this.

delete(list, el)

difference(a, b)

disjoint?(a, b)

intersection(a, b)

member?(list, el)

put(list, el)

size(list)

subset?(a, b)

symmetric_difference(a, b)

to_list(list)

union(a, b)