Debian Codegraph @

README.md

raw symbols SCIP
1 # GoLLRB
2
3 GoLLRB is a Left-Leaning Red-Black (LLRB) implementation of 2-3 balanced binary
4 search trees in Go Language.
5
6 ## Overview
7
8 As of this writing and to the best of the author's knowledge,
9 Go still does not have a balanced binary search tree (BBST) data structure.
10 These data structures are quite useful in a variety of cases. A BBST maintains
11 elements in sorted order under dynamic updates (inserts and deletes) and can
12 support various order-specific queries. Furthermore, in practice one often
13 implements other common data structures like Priority Queues, using BBST's.
14
15 2-3 trees (a type of BBST's), as well as the runtime-similar 2-3-4 trees, are
16 the de facto standard BBST algoritms found in implementations of Python, Java,
17 and other libraries. The LLRB method of implementing 2-3 trees is a recent
18 improvement over the traditional implementation. The LLRB approach was
19 discovered relatively recently (in 2008) by Robert Sedgewick of Princeton
20 University.
21
22 GoLLRB is a Go implementation of LLRB 2-3 trees.
23
24 ## Maturity
25
26 GoLLRB has been used in some pretty heavy-weight machine learning tasks over many gigabytes of data.
27 I consider it to be in stable, perhaps even production, shape. There are no known bugs.
28
29 ## Installation
30
31 With a healthy Go Language installed, simply run `go get github.com/petar/GoLLRB/llrb`
32
33 ## Example
34
35 package main
36
37 import (
38 "fmt"
39 "github.com/petar/GoLLRB/llrb"
40 )
41
42 func lessInt(a, b interface{}) bool { return a.(int) < b.(int) }
43
44 func main() {
45 tree := llrb.New(lessInt)
46 tree.ReplaceOrInsert(1)
47 tree.ReplaceOrInsert(2)
48 tree.ReplaceOrInsert(3)
49 tree.ReplaceOrInsert(4)
50 tree.DeleteMin()
51 tree.Delete(4)
52 c := tree.IterAscend()
53 for {
54 u := <-c
55 if u == nil {
56 break
57 }
58 fmt.Printf("%d\n", int(u.(int)))
59 }
60 }
61
62 ## About
63
64 GoLLRB was written by [Petar Maymounkov](http://pdos.csail.mit.edu/~petar/).
65
66 Follow me on [Twitter @maymounkov](http://www.twitter.com/maymounkov)!