llrb

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key interface {
	// Compare gives the result of a 3-way comparison
	// a.Compare(b) = 1 => a > b
	// a.Compare(b) = 0 => a == b
	// a.Compare(b) = -1 => a < b
	Compare(k Key) int
}

Key represents key of Tree.

type Node

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

Node is a node of Tree.

func NewNode

func NewNode(key Key, value Value, isRed bool) *Node

NewNode creates a new instance of Node.

type Tree

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

Tree is an implementation of Left-learning Red-Black Tree. Original paper on Left-leaning Red-Black Trees:

Invariant 1: No red node has a red child Invariant 2: Every leaf path has the same number of black nodes Invariant 3: Only the left child can be red (left leaning)

func NewTree

func NewTree() *Tree

NewTree creates a new instance of Tree.

func (*Tree) Floor

func (t *Tree) Floor(key Key) (Key, Value)

Floor returns the greatest key less than or equal to the given key.

func (*Tree) Put

func (t *Tree) Put(k Key, v Value) Value

Put puts the value of the given key.

func (*Tree) Remove

func (t *Tree) Remove(key Key)

Remove removes the value of the given key.

func (*Tree) String

func (t *Tree) String() string

type Value

type Value interface {
	String() string
}

Value represents the data stored in the nodes of Tree.

Jump to

Keyboard shortcuts

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