RangeSet (range_set v1.0.0)
Summary
Functions
Determines if the set is continuous (there are no gaps).
Returns difference between sets.
Determines if set is empty.
Returns set that contains all gaps needed to make the range continuous.
Returns intersection between two sets
Computes length of the all ranges combined, aka amount of unique integers in set.
Returns the maximal element in set.
Returns the minimal element in set.
Create new empty set.
Adds new value to set.
Returns list of values stored in set.
Returns union of sets
Types
ranges()
@opaque ranges()
@type t() :: %RangeSet{ranges: ranges()}
Functions
continuous?(range_set)
Determines if the set is continuous (there are no gaps).
difference(range_set, other)
Returns difference between sets.
empty?(range_set)
Determines if set is empty.
iex> RangeSet.empty?(RangeSet.new())
true
iex> RangeSet.empty?(RangeSet.new(1..10))
false
gaps(range_set)
Returns set that contains all gaps needed to make the range continuous.
iex> RangeSet.new([0..2, 6..9]) |> RangeSet.gaps()
RangeSet.new([3..5])
iex> RangeSet.new([0..5, 6..9]) |> RangeSet.gaps()
RangeSet.new([])
intersection(range_set1, range_set2)
Returns intersection between two sets
length(range_set)
@spec length(t()) :: non_neg_integer()
Computes length of the all ranges combined, aka amount of unique integers in set.
max(range_set, empty_callback \\ fn -> raise Enum.EmptyError end)
Returns the maximal element in set.
If set is empty, the provided empty_callback
is called.
Examples
iex> RangeSet.max(RangeSet.new([1..2, 5..10]))
10
member?(range_set, value)
min(range_set, empty_callback \\ fn -> raise Enum.EmptyError end)
Returns the minimal element in set.
If set is empty, the provided empty_callback
is called.
Examples
iex> RangeSet.min(RangeSet.new([1..2, 5..10]))
1
new()
@spec new() :: t()
Create new empty set.
new(set)
@spec new(Range.t()) :: t()
@spec new(Enumerable.t(Range.t())) :: t()
put(range_set, value)
Adds new value to set.
to_list(range_set)
Returns list of values stored in set.
union(range_set1, range_set2)
Returns union of sets