Documentation ¶
Overview ¶
Package rangeset is a library for manipulating sets of non-overlapping non-adjacent ranges.
Index ¶
- type Range
- type RangeSet
- func FromRange(low, high int64) RangeSet
- func Intersection(sets ...RangeSet) RangeSet
- func IntersectionBuffer(s1, s2, buffer RangeSet) RangeSet
- func SymmetricDifference(s1, s2 RangeSet) RangeSet
- func Union(sets ...RangeSet) RangeSet
- func UnionBuffer(s1, s2, buffer RangeSet) RangeSet
- func Universal() RangeSet
- func (set *RangeSet) Add(single int64)
- func (set *RangeSet) AddRange(low, high int64)
- func (set *RangeSet) AddRanges(ranges ...Range)
- func (set RangeSet) Complement() RangeSet
- func (set RangeSet) Contains(single int64) bool
- func (set RangeSet) ContainsAny(low, high int64) bool
- func (set RangeSet) ContainsRange(low, high int64) bool
- func (set RangeSet) Count() uint64
- func (set *RangeSet) Delete(single int64)
- func (set *RangeSet) DeleteRange(low, high int64)
- func (set *RangeSet) DeleteRanges(ranges ...Range)
- func (set RangeSet) Difference(other RangeSet) RangeSet
- func (set RangeSet) Equals(other RangeSet) bool
- func (set RangeSet) Extent() Range
- func (set RangeSet) Intersection(other RangeSet) RangeSet
- func (set RangeSet) IsSubsetOf(other RangeSet) bool
- func (set RangeSet) Union(other RangeSet) RangeSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RangeSet ¶
type RangeSet []Range
A RangeSet is a slice of non-overlapping non-adjacent ordered Ranges. The zero value for a RangeSet, i.e. a nil RangeSet, is an empty set.
Since Range is half-open, you can never add math.MaxInt64 into a RangeSet. Thus, complement of an empty set is [math.MinInt64, math.MaxInt64).
func FromRange ¶ added in v0.1.1
FromRange creates a RangeSet from range [low, high).
If low >= high, FromRange returns nil.
func Intersection ¶ added in v0.2.0
Intersection returns the intersection of zero or more sets.
func IntersectionBuffer ¶ added in v0.2.0
IntersectionBuffer returns the intersection of s1 and s2, uses buffer as its initial backing storage.
func SymmetricDifference ¶ added in v0.2.0
SymmetricDifference returns the symmetric difference of two sets.
func UnionBuffer ¶
UnionBuffer returns the union of s1 and s2, uses buffer as its initial backing storage.
func Universal ¶ added in v0.1.1
func Universal() RangeSet
Universal returns the largest RangeSet, which is the complement of an empty set, i.e. [math.MinInt64, math.MaxInt64).
func (RangeSet) Complement ¶
Complement returns the inverse of set.
func (RangeSet) ContainsAny ¶
ContainsAny reports whether or not set contains any element in range [low, high).
func (RangeSet) ContainsRange ¶
ContainsRange reports whether or not set contains every element in range [low, high).
func (*RangeSet) DeleteRange ¶
DeleteRange removes range [low, high) from set.
func (*RangeSet) DeleteRanges ¶ added in v0.2.0
DeleteRanges removes zero or more half-open ranges from set.
func (RangeSet) Difference ¶ added in v0.2.1
Difference returns the subset of set that having all elements in other excluded.
func (RangeSet) Extent ¶ added in v0.2.0
Extent returns the smallest Range that covers the whole set.
If set is empty, Extent returns the zero value.
func (RangeSet) Intersection ¶ added in v0.2.0
Intersection returns the intersection of set and other.
func (RangeSet) IsSubsetOf ¶ added in v0.2.0
IsSubsetOf reports whether or not other contains every element in set.