Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrInvalidInputTypeOfComparator = errors.New("invalid input type of comparator")
)
Functions ¶
This section is empty.
Types ¶
type BSTree ¶
type BSTree struct {
// contains filtered or unexported fields
}
BSTree is Binary Search Tree
func NewBSTree ¶
func NewBSTree(comparator Comparator) *BSTree
func NewIntBSTree ¶
func NewIntBSTree() *BSTree
func NewStringBSTree ¶
func NewStringBSTree() *BSTree
func (*BSTree) InsertOrReplace ¶
func (t *BSTree) InsertOrReplace(key interface{}, value interface{})
func (*BSTree) PrettyString ¶
func (*BSTree) SearchInsertPosition ¶
type Comparator ¶
type Comparator interface {
Compare(interface{}, interface{}) int
}
Comparetor.Compare returns an integer comparing two object lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
type IntComparator ¶
type IntComparator struct{}
func (*IntComparator) Compare ¶
func (c *IntComparator) Compare(i, j interface{}) int
type Node ¶
type Node struct { Key interface{} Value interface{} Color Color Parent *Node Left *Node Right *Node }
func (*Node) GetGrandparent ¶
func (*Node) GetSibling ¶
type RBTree ¶
type RBTree struct {
*BSTree
}
func NewIntRBTree ¶
func NewIntRBTree() *RBTree
func NewRBTree ¶
func NewRBTree(comparator Comparator) *RBTree
func NewStringRBTree ¶
func NewStringRBTree() *RBTree
func (*RBTree) InsertOrReplace ¶
func (t *RBTree) InsertOrReplace(key interface{}, value interface{})
type StringComparator ¶
type StringComparator struct{}
func (*StringComparator) Compare ¶
func (c *StringComparator) Compare(i, j interface{}) int
Click to show internal directories.
Click to hide internal directories.