mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-13 17:09:46 +08:00
add zig codes for Section 'Hash Map'
This commit is contained in:
@@ -46,6 +46,16 @@ pub fn printLinkedList(comptime T: type, node: ?*ListNode(T)) !void {
|
||||
}
|
||||
}
|
||||
|
||||
// Print a HashMap
|
||||
pub fn printHashMap(comptime TKey: type, comptime TValue: type, map: std.AutoHashMap(TKey, TValue)) void {
|
||||
var it = map.iterator();
|
||||
while (it.next()) |kv| {
|
||||
var key = kv.key_ptr.*;
|
||||
var value = kv.value_ptr.*;
|
||||
std.debug.print("{} -> {s}\n", .{key, value});
|
||||
}
|
||||
}
|
||||
|
||||
// This tree printer is borrowed from TECHIE DELIGHT
|
||||
// https://www.techiedelight.com/c-program-print-binary-tree/
|
||||
const Trunk = struct {
|
||||
|
||||
Reference in New Issue
Block a user