Gyuho Lee ffe90b9ff3 pkg/adt: remove TODO | há 5 anos atrás | |
---|---|---|
.. | ||
img | há 5 anos atrás | |
README.md | há 5 anos atrás | |
doc.go | há 8 anos atrás | |
example_test.go | há 5 anos atrás | |
interval_tree.go | há 5 anos atrás | |
interval_tree_test.go | há 5 anos atrás |
"Introduction to Algorithms" (Cormen et al, 3rd ed.), Chapter 13
For example,
import (
"fmt"
"go.etcd.io/etcd/pkg/adt"
)
func main() {
ivt := adt.NewIntervalTree()
ivt.Insert(NewInt64Interval(510, 511), 0)
ivt.Insert(NewInt64Interval(82, 83), 0)
ivt.Insert(NewInt64Interval(830, 831), 0)
...
After inserting the values 510
, 82
, 830
, 11
, 383
, 647
, 899
, 261
, 410
, 514
, 815
, 888
, 972
, 238
, 292
, 953
.
Deleting the node 514
should not trigger any rebalancing:
Deleting the node 11
triggers multiple rotates for rebalancing:
Try yourself at https://www.cs.usfca.edu/~galles/visualization/RedBlack.html.