Documentation ¶
Index ¶
- type CompareCmd
- type RbNode
- type RbTree
- func (rb *RbTree) DeleteByKey(key interface{})
- func (rb *RbTree) DeleteByNode(z *RbNode)
- func (rb *RbTree) Find(key interface{}) []*RbNode
- func (rb *RbTree) First() *RbNode
- func (rb *RbTree) Insert(key, value interface{})
- func (rb *RbTree) Last() *RbNode
- func (rb *RbTree) Next(node *RbNode) *RbNode
- func (rb *RbTree) Prev(node *RbNode) *RbNode
- func (rb *RbTree) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompareCmd ¶
type CompareCmd func(interface{}, interface{}) int
CompareCmd
-1: less 0: equal 1: more
type RbNode ¶
type RbNode struct {
K, V interface{}
// contains filtered or unexported fields
}
RbNode the red-black tree node
type RbTree ¶
type RbTree struct {
// contains filtered or unexported fields
}
RbTree the structure of red-black tree
func NewRbTree ¶
func NewRbTree(cmp CompareCmd, unique bool) *RbTree
NewRbTree new
cmp: method of key comparison unique: whether to allow duplicate keys
func (*RbTree) DeleteByKey ¶
func (rb *RbTree) DeleteByKey(key interface{})
DeleteByKey delete nodes by key. If unique is false, there may be multiple deleted nodes.
func (*RbTree) DeleteByNode ¶
DeleteByNode delete the node directly.
Click to show internal directories.
Click to hide internal directories.