Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BSTreeNode ¶
type BSTreeNode struct {
Value int
Left *BSTreeNode
Right *BSTreeNode
}
构建一个搜索二叉树
func (*BSTreeNode) Insert ¶
func (n *BSTreeNode) Insert(value int)
func (*BSTreeNode) Search ¶
func (n *BSTreeNode) Search(value int) *BSTreeNode
type GenericTree ¶
type GenericTree[T Ordered] struct { // contains filtered or unexported fields }
GenericTree 结构体存储树的根节点和树的大小
func NewBinarySearchTree ¶
func NewBinarySearchTree[T Ordered]() *GenericTree[T]
NewBinarySearchTree 方法创建一个新的二叉树
func (*GenericTree[T]) Contains ¶
func (b *GenericTree[T]) Contains(val T) bool
Contains 方法返回一个布尔值,指示树中是否包含给定的元素
type Ordered ¶
type Ordered interface {
// Greater returns true if the receiver is greater than the other element.
Greater(other Ordered) bool
// Less returns true if the receiver is less than the other element.
Less(other Ordered) bool
// Equal returns true if the receiver is equal to the other element.
Equal(other Ordered) bool
}
Click to show internal directories.
Click to hide internal directories.