Documentation ¶
Overview ¶
Package ranges keeps track of ranges with arbitrary Data attached. Add()ing a range overrides any previous entries for that same range. Remove() forgets about any ranges in the given range. Get() returns which ranges exist and which don't.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data interface { // Slice returns the Data for a new range with the given start/end bounds. It's guaranteed to be a subset of the previous range. Slice(start, end int64) Data }
Data is whatever you want to store with your ranges. Slice() is called when we're narrowing your range because of Add/Remove calls.
type Entry ¶
Entry is a single range.
func MergeAdjacent ¶
MergeAdjacent merges adjacent ranges together. merge() is called to get the new Data for the merged range. Calls to merge() are guaranteed to have a.End == b.Start. merge() can return false to indicate these shouldn't be merged. MergeAdjacent will try to merge b the range after that if they're adjacent.
type NoData ¶
type NoData struct{}
NoData is the nil implementation of Data. It doesn't store anything but implements the Data interface.
type Ranges ¶
type Ranges struct {
// contains filtered or unexported fields
}
Ranges contains zero or more ranges with their associated data. The zero Ranges is valid.
func (*Ranges) Add ¶
Add a new entry. Overrides any previously existing ranges in the same interval.