Documentation ¶
Overview ¶
Package rangeset is a library for manipulating sets of discrete ranges.
Deprecated: Development moved to https://github.com/b97tsk/intervals.
Index ¶
- type Elem
- type Range
- type RangeSet
- func (set *RangeSet[E]) Add(v E)
- func (set *RangeSet[E]) AddRange(lo, hi E)
- func (set RangeSet[E]) Complement() RangeSet[E]
- func (set RangeSet[E]) Contains(v E) bool
- func (set RangeSet[E]) ContainsRange(lo, hi E) bool
- func (set RangeSet[E]) Count() uint64
- func (set *RangeSet[E]) Delete(v E)
- func (set *RangeSet[E]) DeleteRange(lo, hi E)
- func (set RangeSet[E]) Difference(other RangeSet[E]) RangeSet[E]
- func (set RangeSet[E]) Equal(other RangeSet[E]) bool
- func (set RangeSet[E]) Extent() Range[E]
- func (set RangeSet[E]) Intersection(other RangeSet[E]) RangeSet[E]
- func (set RangeSet[E]) IsSubsetOf(other RangeSet[E]) bool
- func (set RangeSet[E]) Overlaps(other RangeSet[E]) bool
- func (set RangeSet[E]) Union(other RangeSet[E]) RangeSet[E]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Elem ¶ added in v0.5.0
type Elem constraints.Integer
Elem is the type set containing all supported element types.
type Range ¶
type Range[E Elem] struct { Low E // inclusive High E // exclusive }
A Range is a half-open interval of type E.
type RangeSet ¶
A RangeSet is a slice of discrete Ranges sorted in ascending order. The zero value for a RangeSet, i.e. a nil RangeSet, is an empty set.
Since Range is half-open, you can never add the maximum value of E into a RangeSet.
func FromRange ¶ added in v0.1.1
FromRange creates a RangeSet from range [lo, hi).
If lo >= hi, FromRange returns nil.
func Intersection ¶ added in v0.2.0
Intersection returns the intersection of zero or more sets.
func SymmetricDifference ¶ added in v0.2.0
SymmetricDifference returns the symmetric difference of two sets.
func Universal ¶ added in v0.1.1
Universal returns the largest RangeSet, which contains every E except one, the maximum value of E.
func (*RangeSet[E]) AddRange ¶
func (set *RangeSet[E]) AddRange(lo, hi E)
AddRange adds range [lo, hi) into set.
func (RangeSet[E]) Complement ¶
Complement returns the inverse of set.
Complement of an empty set is the return value of Universal[E](), which contains every E except one, the maximum value of E.
func (RangeSet[E]) ContainsRange ¶
ContainsRange reports whether set contains every element in range [lo, hi).
func (*RangeSet[E]) Delete ¶
func (set *RangeSet[E]) Delete(v E)
Delete removes a single element from set.
func (*RangeSet[E]) DeleteRange ¶
func (set *RangeSet[E]) DeleteRange(lo, hi E)
DeleteRange removes range [lo, hi) from set.
func (RangeSet[E]) Difference ¶ added in v0.2.1
Difference returns the subset of set that having all elements in other excluded.
func (RangeSet[E]) 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[E]) Intersection ¶ added in v0.2.0
Intersection returns the intersection of set and other.
func (RangeSet[E]) IsSubsetOf ¶ added in v0.2.0
IsSubsetOf reports whether other contains every element in set.