update zig codes for Section 'Heap' (heap.zig)

This commit is contained in:
sjinzh
2023-01-16 05:30:46 +08:00
parent 87949f6c20
commit 58d5c117f8
3 changed files with 7 additions and 8 deletions
+2 -2
View File
@@ -23,8 +23,8 @@ pub fn TreeNode(comptime T: type) type {
};
}
// Generate a binary tree with an array (through TailQueue)
pub fn arrQueToTree(comptime T: type, mem_allocator: std.mem.Allocator, arr: []T) !?*TreeNode(T) {
// Generate a binary tree with an array
pub fn arrToTree(comptime T: type, mem_allocator: std.mem.Allocator, arr: []T) !?*TreeNode(T) {
if (arr.len == 0) return null;
var root = try mem_allocator.create(TreeNode(T));
root.init(arr[0]);