Documentation ¶
Overview ¶
Package treemap provides a generic key-sorted map. It uses red-black tree under the hood. You can use it as a template to generate a sorted map with specific key and value types. Iterators are designed after C++.
Example:
package main import "fmt" //go:generate gotemplate "github.com/ncw/gotemplate/treemap" "intStringTreeMap(int, string)" func less(x, y int) bool { return x < y } func main() { tr := newIntStringTreeMap(less) tr.Set(0, "Hello") tr.Set(1, "World") for it := tr.Iterator(); it.Valid(); it.Next() { fmt.Println(it.Key(), it.Value()) } }
Click to show internal directories.
Click to hide internal directories.