llrbtree

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Implements Left-Leaning Red Black trees. Structure is not thread safe.

Index

Constants

View Source
const (
	LLRB234 = LLRBMode(0)
	LLRB23  = LLRBMode(1)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LLRBMode

type LLRBMode byte

type Operation

type Operation func(key compare.Comparable, value interface{}) (done bool)

An Operation is a function that operates on a Comparable. If done is returned true, the Operation is indicating that no further work needs to be done and so the Do function should traverse no further.

type Tree

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

A Tree manages the root node of an LLRB tree. Public methods are exposed through this type.

func New

func New(mode LLRBMode) *Tree

func (*Tree) Ceil

func (t *Tree) Ceil(key compare.Comparable) (compare.Comparable, interface{})

Ceil returns the smallest value equal to or greater than the query q according to q.Compare().

func (*Tree) Clear

func (t *Tree) Clear()

func (*Tree) Delete

func (t *Tree) Delete(key compare.Comparable)

func (*Tree) DeleteMax

func (t *Tree) DeleteMax()

func (*Tree) DeleteMin

func (t *Tree) DeleteMin()

func (*Tree) Do

func (t *Tree) Do(fn Operation) bool

Do performs fn on all values stored in the tree. A boolean is returned indicating whether the Do traversal was interrupted by an Operation returning true. If fn alters stored values' sort relationships, future tree operation behaviors are undefined.

func (*Tree) DoMatching

func (t *Tree) DoMatching(fn Operation, q compare.Comparable) bool

DoMatch performs fn on all values stored in the tree that match q according to Compare, with q.Compare() used to guide tree traversal, so DoMatching() will out perform Do() with a called conditional function if the condition is based on sort order, but can not be reliably used if the condition is independent of sort order. A boolean is returned indicating whether the Do traversal was interrupted by an Operation returning true. If fn alters stored values' sort relationships, future tree operation behaviors are undefined.

func (*Tree) DoRange

func (t *Tree) DoRange(fn Operation, from, to compare.Comparable) bool

DoRange performs fn on all values stored in the tree over the interval [from, to) from left to right. If to is less than from DoRange will panic. A boolean is returned indicating whether the Do traversal was interrupted by an Operation returning true. If fn alters stored values' sort relationships future tree operation behaviors are undefined.

func (*Tree) DoRangeReverse

func (t *Tree) DoRangeReverse(fn Operation, from, to compare.Comparable) bool

DoRangeReverse performs fn on all values stored in the tree over the interval (to, from] from right to left. If from is less than to DoRange will panic. A boolean is returned indicating whether the Do traversal was interrupted by an Operation returning true. If fn alters stored values' sort relationships future tree operation behaviors are undefined.

func (*Tree) DoReverse

func (t *Tree) DoReverse(fn Operation) bool

DoReverse performs fn on all values stored in the tree, but in reverse of sort order. A boolean is returned indicating whether the Do traversal was interrupted by an Operation returning true. If fn alters stored values' sort relationships, future tree operation behaviors are undefined.

func (*Tree) Empty

func (t *Tree) Empty() bool

func (*Tree) Floor

func (t *Tree) Floor(key compare.Comparable) (compare.Comparable, interface{})

Floor returns the greatest value equal to or less than the query key according to key.Compare().

func (*Tree) Get

func (t *Tree) Get(key compare.Comparable) (compare.Comparable, interface{})

Get returns the first match of q in the Tree. If insertion without replacement is used, this is probably not what you want.

func (*Tree) Insert

func (t *Tree) Insert(key compare.Comparable, value interface{})

func (*Tree) Keys

func (t *Tree) Keys() []compare.Comparable

func (*Tree) Len

func (t *Tree) Len() int

func (*Tree) Max

func (t *Tree) Max() (compare.Comparable, interface{})

func (*Tree) Min

func (t *Tree) Min() (compare.Comparable, interface{})

func (*Tree) Values

func (t *Tree) Values() []interface{}

Jump to

Keyboard shortcuts

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