According to this link stathat uses overlapping with their treap:
GoLLRB is great and there's no reason you should switch. We thought the idea behind treaps was an elegant solution to our problem, so we implemented it. We liked the interface that GoLLRB provided, so we mimicked it in our implementation.
One thing we added to the treap package is to allow you to iterate using an overlap function, so you can get all the keys in [3,9), for example. We use this a lot, often with a struct as the key.
Patrick
I am playing with the following code and have no idea how to continue:
package main
import(
"reflect"
"fmt"
"github.com/stathat/treap"
)
func IntLess(p, q interface{}) bool {
return p.(int) < q.(int)
}
func BucketOverlap(a, b interface{}) bool {
return false
}
func main() {
tree := treap.NewOverlapTree(IntLess, BucketOverlap)
tree.Insert(5, "a")
tree.Insert(7, "b")
tree.Insert(2, "c")
tree.Insert(1, "d")
for v := range tree.IterateOverlap([]int{2,5}) {
fmt.Printf("val: %v
", v)
}
}
let's say I want to get keys in range [2,5]
=> [c,a]