Documentation ¶
Overview ¶
Package gointervaltree provides functionality for indexing a set of integer intervals, e.g. [start, end) based on http://en.wikipedia.org/wiki/Interval_tree. Copyright 2022, Kirill Danilov. Licensed under MIT license.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewIntervalTree ¶
func NewIntervalTree[T constraints.Signed](min, max T) (*intervalTree[T], error)
NewIntervalTree creates and returns an IntervalTree object.
Example ¶
t, _ := NewIntervalTree(0, 100) _ = t.AddInterval(1, 10, []string{"a", "b"}) _ = t.AddInterval(20, 30, []bool{true, false}) _ = t.AddInterval(32, 35, []int{1, 2, 3}) _ = t.AddInterval(32, 38, nil) t.Sort() fmt.Println(t.Len()) fmt.Println(t.Iter()) fmt.Println(t.Query(33))
Output: 4 [{1 10 [a b]} {32 35 [1 2 3]} {32 38 <nil>} {20 30 [true false]}] [{32 35 [1 2 3]} {32 38 <nil>}]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.