2024-11-06 15:44:28 +01:00
|
|
|
const std = @import("std");
|
|
|
|
|
2024-11-08 20:26:58 +01:00
|
|
|
pub fn LList (comptime T: type) type {
|
2024-11-06 15:44:28 +01:00
|
|
|
return struct {
|
|
|
|
const Self = @This();
|
2024-11-08 20:26:58 +01:00
|
|
|
first: ?*Node(T),
|
|
|
|
|
|
|
|
pub fn init(this: *Self) !void { // ! allocator: *std.mem.allocator als zweiter Parameter
|
|
|
|
this.first = null;
|
2024-11-06 15:44:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn deinit() void {
|
2024-11-06 15:46:19 +01:00
|
|
|
//TODO
|
2024-11-06 15:44:28 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-11-06 16:07:42 +01:00
|
|
|
pub fn Node (comptime T: type) type {
|
2024-11-06 15:44:28 +01:00
|
|
|
return struct {
|
|
|
|
const Self = @This();
|
2024-11-06 16:07:42 +01:00
|
|
|
next: *Self, //? Nächste Node in der Liste
|
2024-11-06 15:44:28 +01:00
|
|
|
|
|
|
|
|
2024-11-06 16:07:42 +01:00
|
|
|
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});
|
2024-11-06 15:44:28 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() !void {
|
2024-11-06 16:07:42 +01:00
|
|
|
var testList: LLIst(u64) = undefined;
|
|
|
|
try testList.init();
|
2024-11-06 15:44:28 +01:00
|
|
|
}
|