Fix bugs and harmonize the code comments (#1199)

* Fix the comment in array_deque.go

* Fix the comment in bucket_sort.c

* Translate the Java code comments to Chinese

* Bug fixes

* 二分查找 -> 二分搜尋

* Harmonize comments in `utils` between multiple programming languages
This commit is contained in:
Yudong Jin
2024-03-31 03:06:41 +08:00
committed by GitHub
parent cfe8281aee
commit 034ee65e9a
35 changed files with 133 additions and 271 deletions

View File

@@ -11,13 +11,13 @@ import (
"strings"
)
// PrintSlice Print a slice
// PrintSlice 打印切片
func PrintSlice[T any](nums []T) {
fmt.Printf("%v", nums)
fmt.Println()
}
// PrintList Print a list
// PrintList 打印列表
func PrintList(list *list.List) {
if list.Len() == 0 {
fmt.Print("[]\n")
@@ -33,14 +33,14 @@ func PrintList(list *list.List) {
fmt.Print(e.Value, "]\n")
}
// PrintMap Print a hash map
// PrintMap 打印哈希表
func PrintMap[K comparable, V any](m map[K]V) {
for key, value := range m {
fmt.Println(key, "->", value)
}
}
// PrintHeap Print a heap
// PrintHeap 打印堆
func PrintHeap(h []any) {
fmt.Printf("堆的数组表示:")
fmt.Printf("%v", h)
@@ -49,7 +49,7 @@ func PrintHeap(h []any) {
PrintTree(root)
}
// PrintLinkedList Print a linked list
// PrintLinkedList 打印链表
func PrintLinkedList(node *ListNode) {
if node == nil {
return
@@ -63,12 +63,12 @@ func PrintLinkedList(node *ListNode) {
fmt.Println(builder.String())
}
// PrintTree Print a binary tree
// PrintTree 打印二叉树
func PrintTree(root *TreeNode) {
printTreeHelper(root, nil, false)
}
// printTreeHelper Help to print a binary tree, hide more details
// printTreeHelper 打印二叉树
// This tree printer is borrowed from TECHIE DELIGHT
// https://www.techiedelight.com/c-program-print-binary-tree/
func printTreeHelper(root *TreeNode, prev *trunk, isRight bool) {
@@ -96,7 +96,6 @@ func printTreeHelper(root *TreeNode, prev *trunk, isRight bool) {
printTreeHelper(root.Left, trunk, false)
}
// trunk Help to print tree structure
type trunk struct {
prev *trunk
str string