Documentation
¶
Overview ¶
Package rangeset implements a half-open interval set [start, end). It is intended to be used for working with many large ranges of valid or invalid rows.
Index ¶
- type Range
- type Set
- func (s *Set) Add(r Range)
- func (s *Set) IncludesRange(r Range) bool
- func (s *Set) IncludesValue(value uint64) bool
- func (s *Set) Iter() iter.Seq[Range]
- func (s *Set) Len() int
- func (s *Set) Next(value uint64) (uint64, bool)
- func (s *Set) Overlaps(r Range) bool
- func (s *Set) RangeFor(value uint64) Range
- func (s *Set) Reset()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Range ¶
Range is a half-open interval [Start, End).
Invariant: Start < End
func (Range) ContainsRange ¶
ContainsRange returns true if all rows in other are inside r.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set holds a sorted list of non-overlapping [Range]s. The zero value is ready for use.
func From ¶
From creates a new Set from a slice of ranges. Invalid ranges (those of length zero or negative length) are ignored.
func (*Set) Add ¶
Add inserts r into s. If r overlaps with any existing ranges in s, the ranges are merged.
func (*Set) IncludesRange ¶
IncludesRange returns true if the range r is fully contained inside s.
func (*Set) IncludesValue ¶
IncludesValue returns true if the set contains the value.
func (*Set) Next ¶
Next returns the next value in s after the given value. If there are no more values in s after value, Next returns math.MaxUint64 and false.
func (*Set) Overlaps ¶
Overlaps returns true if r overlaps with s, false if no value in r is found in s.