rangeset

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: EUPL-1.2 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIndex = errors.New("index out of range of RangeSet")

Functions

This section is empty.

Types

type RangeEntry

type RangeEntry[T any] struct {
	Start T
	End   T
}

type RangeSet

type RangeSet[T any] struct {
	// the merged ranges
	Ranges *btree.BTreeG[RangeEntry[T]]
	// a three-way comparison function like strcmp;
	// 0 for equality, -1 for v1 < v2, 1 for v1 > v2
	Compare func(v1, v2 T) int
	// a sentinel value indicating wrapping around from this value from the end to the start
	// if HasWrap is true and the final value is this, then any value sorting after it
	// is considered within the range
	RWrapV T
	// whether or not there is a "wraparound value" on the right side
	HasRWrap bool
	// contains filtered or unexported fields
}

container for arbitrary ranges of values

func NewRangeset added in v1.1.0

func NewRangeset[T any](compare func(v1, v2 T) int, rwrapV T, hasWrap bool) *RangeSet[T]

func (*RangeSet[T]) Add

func (r *RangeSet[T]) Add(newEntry RangeEntry[T])

add a range, potentially expanding or merging existing ranges

func (*RangeSet[T]) Contains

func (r *RangeSet[T]) Contains(v T) bool

check whether a given value is contained within the range set

func (*RangeSet[T]) ContainsRange

func (r *RangeSet[T]) ContainsRange(rn RangeEntry[T]) bool

func (*RangeSet[T]) Get added in v1.2.0

func (r *RangeSet[T]) Get(idx int) (RangeEntry[T], error)

func (*RangeSet[T]) Items added in v1.2.0

func (r *RangeSet[T]) Items() []RangeEntry[T]

func (*RangeSet[T]) Iter added in v1.2.0

func (r *RangeSet[T]) Iter() iter.Seq[RangeEntry[T]]

func (*RangeSet[T]) Len added in v1.2.0

func (r *RangeSet[T]) Len() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL