Documentation ¶
Overview ¶
Package interval implements algorithms that operate on lists of intervals.
Index ¶
- func Contains(l List, value uint64) bool
- func IndexOf(l List, value uint64) int
- func Intersect(l List, span U64Span) (first, count int)
- func Merge(l MutableList, span U64Span, joinAdj bool) int
- func Remove(l MutableList, span U64Span)
- func Replace(l MutableList, span U64Span) int
- func Search(l List, t Predicate) int
- type List
- type MutableList
- type Predicate
- type U64Range
- type U64RangeList
- func (l U64RangeList) Clone() U64RangeList
- func (l U64RangeList) Copy(to, from, count int)
- func (l U64RangeList) GetSpan(index int) U64Span
- func (l U64RangeList) Length() int
- func (l U64RangeList) New(index int, span U64Span)
- func (l *U64RangeList) Resize(length int)
- func (l U64RangeList) SetSpan(index int, span U64Span)
- type U64Span
- type U64SpanList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Merge ¶
func Merge(l MutableList, span U64Span, joinAdj bool) int
Merge adds a span to the list, merging it with existing spans if it overlaps them, and returns the index of that span. If the joinAdj parameter is true, then any intervals that are immediately adjacent to span will be merged with span. For example, consider the merging of intervals [0, 2] and [3, 5]:
When joinAdj == false:
╭ ╮ ╭ ╮ ╭ ╮╭ ╮ │0 1 2│ merge │3 4 5│ = │0 1 2││3 4 5│ ╰ ╯ ╰ ╯ ╰ ╯╰ ╯
When join == true:
╭ ╮ ╭ ╮ ╭ ╮ │0 1 2│ merge │3 4 5│ = │0 1 2 3 4 5│ ╰ ╯ ╰ ╯ ╰ ╯
func Remove ¶
func Remove(l MutableList, span U64Span)
Remove strips the specified span from the list, cutting it out of any overlapping intervals
func Replace ¶
func Replace(l MutableList, span U64Span) int
Replace cuts the span out of any existing intervals, and then adds a new interval, and returns its index.
Types ¶
type List ¶
type List interface { // Length returns the number of elements in the list Length() int // GetSpan returns the span for the element at index in the list GetSpan(index int) U64Span }
List is the interface to an object that can be used as an interval list by the algorithms in this package.
type MutableList ¶
type MutableList interface { List // SetSpan sets the span for the element at index in the list SetSpan(index int, span U64Span) // New creates a new element at the specifed index with the specified span New(index int, span U64Span) // Copy count list entries Copy(to, from, count int) // Resize adjusts the length of the array Resize(length int) }
MutableList is a mutable form of a List.
type U64Range ¶
type U64Range struct { First uint64 // the first value in the interval Count uint64 // the count of values in the interval }
U64Range is an interval specified by a beginning and size.
type U64RangeList ¶
type U64RangeList []U64Range
U64RangeList implements List for an array of U64Range intervals
func (U64RangeList) Clone ¶
func (l U64RangeList) Clone() U64RangeList
func (U64RangeList) Copy ¶
func (l U64RangeList) Copy(to, from, count int)
func (U64RangeList) GetSpan ¶
func (l U64RangeList) GetSpan(index int) U64Span
func (U64RangeList) Length ¶
func (l U64RangeList) Length() int
func (U64RangeList) New ¶
func (l U64RangeList) New(index int, span U64Span)
func (*U64RangeList) Resize ¶
func (l *U64RangeList) Resize(length int)
func (U64RangeList) SetSpan ¶
func (l U64RangeList) SetSpan(index int, span U64Span)
type U64Span ¶
type U64Span struct { Start uint64 // the value at which the interval begins End uint64 // the next value not included in the interval. }
U64Span is the base interval type understood by the algorithms in this package. It is a half open interval that includes the lower bound, but not the upper.
type U64SpanList ¶
type U64SpanList []U64Span
U64SpanList implements List for an array of U64Span intervals
func (U64SpanList) Copy ¶
func (l U64SpanList) Copy(to, from, count int)
func (U64SpanList) GetSpan ¶
func (l U64SpanList) GetSpan(index int) U64Span
func (U64SpanList) Length ¶
func (l U64SpanList) Length() int
func (U64SpanList) New ¶
func (l U64SpanList) New(index int, span U64Span)
func (*U64SpanList) Resize ¶
func (l *U64SpanList) Resize(length int)
func (U64SpanList) SetSpan ¶
func (l U64SpanList) SetSpan(index int, span U64Span)