You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
483 B
21 lines
483 B
2 years ago
|
// File: TreeNode.zig
|
||
|
// Created Time: 2023-01-07
|
||
|
// Author: sjinzh (sjinzh@gmail.com)
|
||
|
|
||
|
const std = @import("std");
|
||
|
|
||
|
// Definition for a binary tree node
|
||
|
pub fn TreeNode(comptime T: type) type {
|
||
|
return struct {
|
||
|
const Self = @This();
|
||
|
|
||
|
val: T = undefined,
|
||
|
left: ?*Self = null,
|
||
|
right: ?*Self = null,
|
||
|
|
||
|
// Initialize a tree node with specific value
|
||
|
pub fn init(self: *Self, x: i32) void {
|
||
|
self.val = x;
|
||
|
}
|
||
|
};
|
||
|
}
|