mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-24 10:33:34 +08:00
refactor: Replace 结点 with 节点 (#452)
* Replace 结点 with 节点 Update the footnotes in the figures * Update mindmap * Reduce the size of the mindmap.png
This commit is contained in:
@@ -15,7 +15,7 @@ fn hashingSearchArray(comptime T: type, map: std.AutoHashMap(T, T), target: T) T
|
||||
|
||||
// 哈希查找(链表)
|
||||
fn hashingSearchLinkedList(comptime T: type, map: std.AutoHashMap(T, *inc.ListNode(T)), target: T) ?*inc.ListNode(T) {
|
||||
// 哈希表的 key: 目标结点值,value: 结点对象
|
||||
// 哈希表的 key: 目标节点值,value: 节点对象
|
||||
// 若哈希表中无此 key ,返回 null
|
||||
if (map.getKey(target) == null) return null;
|
||||
return map.get(target);
|
||||
@@ -49,7 +49,7 @@ pub fn main() !void {
|
||||
head = head.?.next;
|
||||
}
|
||||
var node = hashingSearchLinkedList(i32, map1, target);
|
||||
std.debug.print("目标结点值 3 的对应结点对象为 ", .{});
|
||||
std.debug.print("目标节点值 3 的对应节点对象为 ", .{});
|
||||
try inc.PrintUtil.printLinkedList(i32, node);
|
||||
|
||||
_ = try std.io.getStdIn().reader().readByte();
|
||||
|
||||
@@ -23,7 +23,7 @@ pub fn linearSearchLinkedList(comptime T: type, node: ?*inc.ListNode(T), target:
|
||||
var head = node;
|
||||
// 遍历链表
|
||||
while (head != null) {
|
||||
// 找到目标结点,返回之
|
||||
// 找到目标节点,返回之
|
||||
if (head.?.val == target) return head;
|
||||
head = head.?.next;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ pub fn main() !void {
|
||||
const mem_allocator = mem_arena.allocator();
|
||||
var head = try inc.ListUtil.listToLinkedList(i32, mem_allocator, nums);
|
||||
var node = linearSearchLinkedList(i32, head, target);
|
||||
std.debug.print("目标结点值 3 的对应结点对象为 ", .{});
|
||||
std.debug.print("目标节点值 3 的对应节点对象为 ", .{});
|
||||
try inc.PrintUtil.printLinkedList(i32, node);
|
||||
|
||||
_ = try std.io.getStdIn().reader().readByte();
|
||||
|
||||
Reference in New Issue
Block a user