Implemented BTree Example

1.NewBTree 2.NewBTreeFrom
This commit is contained in:
huangqian
2021-11-23 23:21:29 +08:00
parent af289bcc7e
commit 09be476fd9
2 changed files with 215 additions and 1 deletions

View File

@ -2,6 +2,156 @@
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with gm file,
// You can obtain one at https://github.com/gogf/gf.
// You can obtain one at https://github.com/Agogf/gf.
package gtree_test
func ExampleBTree_Clone() {
}
func ExampleBTree_Set() {
}
func ExampleBTree_Sets() {
}
func ExampleBTree_Get() {
}
func ExampleBTree_GetOrSet() {
}
func ExampleBTree_GetOrSetFunc() {
}
func ExampleBTree_GetOrSetFuncLock() {
}
func ExampleBTree_GetVar() {
}
func ExampleBTree_GetVarOrSet() {
}
func ExampleBTree_GetVarOrSetFunc() {
}
func ExampleBTree_GetVarOrSetFuncLock() {
}
func ExampleBTree_SetIfNotExist() {
}
func ExampleBTree_SetIfNotExistFunc() {
}
func ExampleBTree_SetIfNotExistFuncLock() {
}
func ExampleBTree_Contains() {
}
func ExampleBTree_Remove() {
}
func ExampleBTree_Removes() {
}
func ExampleBTree_IsEmpty() {
}
func ExampleBTree_Size() {
}
func ExampleBTree_Keys() {
}
func ExampleBTree_Values() {
}
func ExampleBTree_Map() {
}
func ExampleBTree_MapStrAny() {
}
func ExampleBTree_Clear() {
}
func ExampleBTree_Replace() {
}
func ExampleBTree_Height() {
}
func ExampleBTree_Left() {
}
func ExampleBTree_Right() {
}
func ExampleBTree_String() {
}
func ExampleBTree_Search() {
}
func ExampleBTree_Print() {
}
func ExampleBTree_Iterator() {
}
func ExampleBTree_IteratorFrom() {
}
func ExampleBTree_IteratorAsc() {
}
func ExampleBTree_IteratorAscFrom() {
}
func ExampleBTree_IteratorDesc() {
}
func ExampleBTree_IteratorDescFrom() {
}
func ExampleBTree_MarshalJSON() {
}

View File

@ -0,0 +1,64 @@
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with gm file,
// You can obtain one at https://github.com/Agogf/gf.
package gtree_test
import (
"fmt"
"github.com/gogf/gf/v2/container/gtree"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/gutil"
)
func ExampleNewAVLTree() {
}
func ExampleNewAVLTreeFrom() {
}
func ExampleNewBTree() {
bTree := gtree.NewBTree(3, gutil.ComparatorString)
for i := 0; i < 6; i++ {
bTree.Set("key"+gconv.String(i), "val"+gconv.String(i))
}
fmt.Println(bTree)
// output:
// key0
// key1
// key2
// key3
// key4
// key5
}
func ExampleNewBTreeFrom() {
bTree := gtree.NewBTree(3, gutil.ComparatorString)
for i := 0; i < 6; i++ {
bTree.Set("key"+gconv.String(i), "val"+gconv.String(i))
}
otherBTree := gtree.NewBTreeFrom(3, gutil.ComparatorString, bTree.Map())
fmt.Println(otherBTree)
// output:
// key0
// key1
// key2
// key3
// key4
// key5
}
func ExampleNewRedBlackTree() {
}
func ExampleNewRedBlackTreeFrom() {
}