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

@ -12,7 +12,7 @@ public class Trunk(Trunk? prev, string str) {
};
public static class PrintUtil {
/* Print a list */
/* 打印列表 */
public static void PrintList<T>(IList<T> list) {
Console.WriteLine("[" + string.Join(", ", list) + "]");
}
@ -21,7 +21,7 @@ public static class PrintUtil {
return $"[ {string.Join(", ", list.Select(x => x?.ToString() ?? "null"))} ]";
}
/* Print a matrix (Array) */
/* 打印矩阵 (Array) */
public static void PrintMatrix<T>(T[][] matrix) {
Console.WriteLine("[");
foreach (T[] row in matrix) {
@ -30,7 +30,7 @@ public static class PrintUtil {
Console.WriteLine("]");
}
/* Print a matrix (List) */
/* 打印矩阵 (List) */
public static void PrintMatrix<T>(List<List<T>> matrix) {
Console.WriteLine("[");
foreach (List<T> row in matrix) {
@ -39,7 +39,7 @@ public static class PrintUtil {
Console.WriteLine("]");
}
/* Print a linked list */
/* 打印链表 */
public static void PrintLinkedList(ListNode? head) {
List<string> list = [];
while (head != null) {
@ -50,7 +50,7 @@ public static class PrintUtil {
}
/**
* The interface of the tree printer
* 打印二叉树
* This tree printer is borrowed from TECHIE DELIGHT
* https://www.techiedelight.com/c-program-print-binary-tree/
*/
@ -58,7 +58,7 @@ public static class PrintUtil {
PrintTree(root, null, false);
}
/* Print a binary tree */
/* 打印二叉树 */
public static void PrintTree(TreeNode? root, Trunk? prev, bool isRight) {
if (root == null) {
return;
@ -90,7 +90,6 @@ public static class PrintUtil {
PrintTree(root.left, trunk, false);
}
/* Helper function to print branches of the binary tree */
public static void ShowTrunks(Trunk? p) {
if (p == null) {
return;
@ -100,14 +99,14 @@ public static class PrintUtil {
Console.Write(p.str);
}
/* Print a hash map */
/* 打印哈希表 */
public static void PrintHashMap<K, V>(Dictionary<K, V> map) where K : notnull {
foreach (var kv in map.Keys) {
Console.WriteLine(kv.ToString() + " -> " + map[kv]?.ToString());
}
}
/* Print a heap */
/* 打印堆 */
public static void PrintHeap(Queue<int> queue) {
Console.Write("堆的数组表示:");
List<int> list = [.. queue];
@ -117,7 +116,7 @@ public static class PrintUtil {
PrintTree(tree);
}
/* Print a PriorityQueue */
/* 打印优先队列 */
public static void PrintHeap(PriorityQueue<int, int> queue) {
var newQueue = new PriorityQueue<int, int>(queue.UnorderedItems, queue.Comparer);
Console.Write("堆的数组表示:");