dltree

package
v0.0.0-...-66ceba8 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package dltree implements red-black tree for key value pairs with domain label keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pair

type Pair struct {
	Key   string
	Value interface{}
}

Pair is a key-value pair representing tree node content.

type Tree

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

Tree is a red-black tree for key-value pairs where key is domain label.

func NewTree

func NewTree() *Tree

NewTree creates empty tree.

func (*Tree) Delete

func (t *Tree) Delete(key string) (*Tree, bool)

Delete removes node by given key. It returns copy of tree and true if node has been indeed deleted otherwise copy of tree and false.

func (*Tree) Dot

func (t *Tree) Dot() string

Dot dumps tree to Graphviz .dot format.

func (*Tree) Enumerate

func (t *Tree) Enumerate() chan Pair

Enumerate returns channel which is populated by key pair values in order of keys.

func (*Tree) Get

func (t *Tree) Get(key string) (interface{}, bool)

Get returns value by given key.

func (*Tree) InplaceInsert

func (t *Tree) InplaceInsert(key string, value interface{})

InplaceInsert inserts or replaces given key-value pair in the tree. The method inserts data directly to current tree so make sure you have exclusive access to it.

func (*Tree) Insert

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

Insert puts given key-value pair to the tree and returns pointer to new root.

func (*Tree) IsEmpty

func (t *Tree) IsEmpty() bool

IsEmpty returns true if given tree has no nodes.

func (*Tree) RawDelete

func (t *Tree) RawDelete(key string) (*Tree, bool)

RawDelete removes node by given key. It returns copy of tree and true if node has been indeed deleted otherwise copy of tree and false. Expects bindary domain label on input.

func (*Tree) RawEnumerate

func (t *Tree) RawEnumerate() chan Pair

RawEnumerate returns channel which is populated by key pair values in order of keys. Returns binary domain labels.

func (*Tree) RawGet

func (t *Tree) RawGet(key string) (interface{}, bool)

RawGet returns value by given key. Expects bindary domain label on input.

func (*Tree) RawInplaceInsert

func (t *Tree) RawInplaceInsert(key string, value interface{})

RawInplaceInsert inserts or replaces given key-value pair in the tree. The method inserts data directly to current tree so make sure you have exclusive access to it. Expects bindary domain label on input.

func (*Tree) RawInsert

func (t *Tree) RawInsert(key string, value interface{}) *Tree

RawInsert puts given key-value pair to the tree and returns pointer to new root. Expects bindary domain label on input.

Jump to

Keyboard shortcuts

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