rbtree

package module
v0.0.0-...-ff40b15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2018 License: GPL-2.0 Imports: 2 Imported by: 2

README

RbTree

Go Walker GoDoc

Red-Black Tree written in Go.

Documentation

Index

Constants

View Source
const (
	RED   = 0
	BLACK = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Left, Right *Node

	Key   int
	Value interface{}
	// contains filtered or unexported fields
}

func (*Node) Next

func (n *Node) Next() *Node

Next return the node's successor as an iterator

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

func NewTree

func NewTree() *Tree

NewTree return a new rbtree

func (*Tree) Clear

func (t *Tree) Clear()

Clear destroy the rbtree

func (*Tree) Delete

func (t *Tree) Delete(key int)

Delete delete the node by key

func (*Tree) Empty

func (t *Tree) Empty() bool

Empty check whether the rbtree is empty

func (*Tree) Find

func (t *Tree) Find(key int) interface{}

Find find the node and return its value

func (*Tree) FindIt

func (t *Tree) FindIt(key int) *Node

FindIt find the node and return it as a iterator

func (*Tree) GetRoot

func (t *Tree) GetRoot() (*Node, error)

func (*Tree) Insert

func (t *Tree) Insert(key int, value interface{})

Insert insert the key-value pair into the rbtree

func (*Tree) Iterator

func (t *Tree) Iterator() *Node

Iterator create the rbtree's iterator that points to the minmum node

func (*Tree) Preorder

func (t *Tree) Preorder()

func (*Tree) Size

func (t *Tree) Size() int

Size return the size of the rbtree

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL