pmap

package
v0.0.0-...-ab47e86 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//RED represents red color of node
	RED = 0
	//BLACK represents black color of node
	BLACK = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MKey

type MKey int

MKey is int

type MValue

type MValue interface{}

MValue is map value

type Node

type Node struct {
	Left  *Node
	Right *Node
	Color int
	Key   MKey
	Val   MValue
}

Node is node of tree

type NodeHandler

type NodeHandler interface {
	HandleSameKey(*Node, MKey, MValue) *Node
	MarkDeletion(*Node, MKey, MValue) (*Node, bool)
}

NodeHandler is interface

type RBMap

type RBMap struct {
	Root *Node

	Handler NodeHandler
	// contains filtered or unexported fields
}

RBMap is Red-Black tree

func NewRBMap

func NewRBMap() *RBMap

NewRBMap returns new map

func NewRBMapWithHandler

func NewRBMapWithHandler(nhandler NodeHandler) *RBMap

NewRBMapWithHandler returns new map with handler

func (*RBMap) Count

func (rbm *RBMap) Count() int

Count return number of items in RBMap

func (*RBMap) Equals

func (rbm *RBMap) Equals(other *RBMap) bool

Equals return true if maps are equal, false otherwise

func (*RBMap) Get

func (rbm *RBMap) Get(key MKey) (MValue, bool)

Get finds item from map

func (*RBMap) IsEmpty

func (rbm *RBMap) IsEmpty() bool

IsEmpty is true if map is empty, otherwise true

func (*RBMap) Keys

func (rbm *RBMap) Keys() (keys []MKey)

Keys returns list of all keys in map

func (*RBMap) Modify

func (rbm *RBMap) Modify(key MKey, val MValue) (*RBMap, bool)

Modify copies path with modified value

func (*RBMap) Print

func (rbm *RBMap) Print()

Print prints map

func (*RBMap) Put

func (rbm *RBMap) Put(key MKey, val MValue) *RBMap

Put puts value to map

func (*RBMap) Values

func (rbm *RBMap) Values() (values []MValue)

Values returns list of all values in map

func (*RBMap) VisitAll

func (rbm *RBMap) VisitAll(visitor func(*Node))

VisitAll visits all nodes and calls handler

Jump to

Keyboard shortcuts

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