diff options
author | Julien Dessaux | 2022-02-20 23:17:50 +0100 |
---|---|---|
committer | Julien Dessaux | 2022-02-20 23:17:50 +0100 |
commit | 6997d07ac8319ce96b05e312adce36ce04b6ae6a (patch) | |
tree | 35257f9ec55fc1d44cb43349d9660e5ba52a9aaf /src/stackStack.zig | |
parent | Rewrote stack tests (diff) | |
download | zigfunge98-6997d07ac8319ce96b05e312adce36ce04b6ae6a.tar.gz zigfunge98-6997d07ac8319ce96b05e312adce36ce04b6ae6a.tar.bz2 zigfunge98-6997d07ac8319ce96b05e312adce36ce04b6ae6a.zip |
Simplified the stack stack code
Diffstat (limited to '')
-rw-r--r-- | src/stackStack.zig | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/stackStack.zig b/src/stackStack.zig index 820010f..15578d3 100644 --- a/src/stackStack.zig +++ b/src/stackStack.zig @@ -11,33 +11,18 @@ pub const StackStack = struct { } self.data.deinit(); } - pub fn duplicate(self: *StackStack) !void { - return self.toss.*.duplicate(); - } pub fn init(allocator: std.mem.Allocator) !StackStack { var ss = std.ArrayList(stack.Stack).init(allocator); errdefer ss.deinit(); - var toss = try ss.addOne(); - toss.* = stack.Stack.init(allocator); + var s = try ss.addOne(); + s.* = stack.Stack.init(allocator); return StackStack{ .data = ss, - .toss = toss, + .toss = s, }; } - pub fn pop(self: *StackStack) i64 { - return self.toss.*.pop(); - } - pub fn popVector(self: *StackStack) [2]i64 { - return self.toss.*.popVector(); - } - pub fn push(self: *StackStack, n: i64) !void { - return self.toss.*.append(n); - } - pub fn pushVector(self: *StackStack, v: [2]i64) !void { - return self.toss.*.pushVector(v); - } - pub fn swap(self: *StackStack) !void { - return self.toss.*.swap(); + pub inline fn toss(self: *StackStack) *stack.Stack { + return self.toss; } }; |