PR3L-Verkettete-Listen-Abgabe2/LList.zig

38 lines
866 B
Zig

const std = @import("std");
pub fn LList (comptime T: type) type {
return struct {
const Self = @This();
first: ?*Node(T),
pub fn init(this: *Self) !void { // ! allocator: *std.mem.allocator als zweiter Parameter
this.first = null;
}
pub fn deinit() void {
//TODO
}
};
}
pub fn Node (comptime T: type) type {
return struct {
const Self = @This();
next: *Self, //? Nächste Node in der Liste
pub fn init(this: *Self, value: T) void {
this.value = value;
}
pub fn printNode(this: *Self) !void {
const writer = std.io.getStdOut().writer();
try writer.print("Value: {any} \n", .{this.value});
}
};
}
pub fn main() !void {
var testList: LLIst(u64) = undefined;
try testList.init();
}