mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
Add code source blocks to the chapter Graph.
Fix "函数" and "方法"
This commit is contained in:
@@ -12,14 +12,14 @@ pub fn ArrayStack(comptime T: type) type {
|
||||
|
||||
stack: ?std.ArrayList(T) = null,
|
||||
|
||||
// 构造函数(分配内存+初始化栈)
|
||||
// 构造方法(分配内存+初始化栈)
|
||||
pub fn init(self: *Self, allocator: std.mem.Allocator) void {
|
||||
if (self.stack == null) {
|
||||
self.stack = std.ArrayList(T).init(allocator);
|
||||
}
|
||||
}
|
||||
|
||||
// 析构函数(释放内存)
|
||||
// 析构方法(释放内存)
|
||||
pub fn deinit(self: *Self) void {
|
||||
if (self.stack == null) return;
|
||||
self.stack.?.deinit();
|
||||
|
||||
Reference in New Issue
Block a user