diff --git a/LList.zig b/LList.zig index 2689ca8..95fa817 100644 --- a/LList.zig +++ b/LList.zig @@ -3,12 +3,15 @@ const std = @import("std"); pub fn LLIst (comptime T: type) type { return struct { const Self = @This(); + first: *Node(T), + //TODO Liste mit allen Nodes erstellen - // nur um den compiler zufrieden zu stellen šŸ˜” - const _: T = undefined; - - pub fn init() void { - //TODO + pub fn init(this: *Self) !void { + //TODO Heap mit allocater nutzen + var node: Node(T) = undefined; + node.init(69); + try node.printNode(); + this.first = &node; } pub fn deinit() void { @@ -17,20 +20,26 @@ pub fn LLIst (comptime T: type) type { }; } -pub fn Node () type { +pub fn Node (comptime T: type) type { return struct { - comptime T: type = undefined, const Self = @This(); + next: *Self, //? NƤchste Node in der Liste - const next: *Self = undefined; - //var value: T = undefined; + position: i64, //? Position der Node in der List, spƤter Ć¼bergeben mit zB List.len + value: T, - pub fn init(this: *Self, comptime T: type) void { - this.T = T; + 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(); } \ No newline at end of file