odmap

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color int8

Color is rbtree's colour

const (
	// Red colour
	Red Color = 0
	// Black colour
	Black Color = 1
)

type Iterator

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

Iterator : the map's iterator

func (Iterator) IsEnd

func (it Iterator) IsEnd() bool

IsEnd check node is last

func (Iterator) Next

func (it Iterator) Next() Iterator

Next return current right node

func (Iterator) Pre

func (it Iterator) Pre() Iterator

Pre return current left node

func (Iterator) Value

func (it Iterator) Value() *Paire

Value return node data

type Map

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

Map by rbtree

func (*Map) Begin

func (m *Map) Begin() Iterator

Begin return left node

func (*Map) Clear

func (m *Map) Clear()

Clear remove all nodes

func (*Map) End

func (m *Map) End() Iterator

End return empty node, for cmpaire Instead by Iterator.IsEnd

func (*Map) Erase

func (m *Map) Erase(it Iterator)

Erase is remove a node

func (*Map) Find

func (m *Map) Find(key interface{}) Iterator

Find is find node by key

func (*Map) Init

func (m *Map) Init(less func(a, b interface{}) bool) *Map

Init is the map constructor

func (*Map) Rbegin

func (m *Map) Rbegin() Iterator

Rbegin return right node

func (*Map) Remove

func (m *Map) Remove(key interface{})

Remove is remove node by key

func (*Map) Set

func (m *Map) Set(key, value interface{}) Iterator

Set is add a k:v paire into map

func (*Map) Size

func (m *Map) Size() uint64

Size return nodes

type Paire

type Paire struct {
	Value interface{}
	// contains filtered or unexported fields
}

Paire is Node Data

func (*Paire) Key

func (p *Paire) Key() interface{}

Key method return the Node Key

type RbTree

type RbTree struct {
	Root *TreeNode
	// contains filtered or unexported fields
}

RbTree is Red/Black tree

func (*RbTree) Begin

func (rbt *RbTree) Begin() *TreeNode

Begin return the left node

func (*RbTree) Find

func (rbt *RbTree) Find(key interface{}) (isParent bool, r *TreeNode)

Find : get node on key

func (*RbTree) Init

func (rbt *RbTree) Init(less func(a, b interface{}) bool) *RbTree

Init is struct initializer

func (*RbTree) Insert

func (rbt *RbTree) Insert(parent, node *TreeNode)

Insert : add node

func (*RbTree) Rbegin

func (rbt *RbTree) Rbegin() *TreeNode

Rbegin return the right node

func (*RbTree) Remove

func (rbt *RbTree) Remove(node *TreeNode)

Remove is remove node

type TreeNode

type TreeNode struct {
	Left   *TreeNode
	Right  *TreeNode
	Parent *TreeNode
	// contains filtered or unexported fields
}

TreeNode is node of the red/black tree

func (*TreeNode) Get

func (t *TreeNode) Get() *Paire

Get return Node Data

func (*TreeNode) Next

func (t *TreeNode) Next() *TreeNode

Next is right node of the current

func (*TreeNode) Pre

func (t *TreeNode) Pre() *TreeNode

Pre is left node of the current

Jump to

Keyboard shortcuts

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