Simplified the stack stack code
This commit is contained in:
parent
8bd793daf0
commit
6997d07ac8
1 changed files with 5 additions and 20 deletions
|
@ -11,33 +11,18 @@ pub const StackStack = struct {
|
||||||
}
|
}
|
||||||
self.data.deinit();
|
self.data.deinit();
|
||||||
}
|
}
|
||||||
pub fn duplicate(self: *StackStack) !void {
|
|
||||||
return self.toss.*.duplicate();
|
|
||||||
}
|
|
||||||
pub fn init(allocator: std.mem.Allocator) !StackStack {
|
pub fn init(allocator: std.mem.Allocator) !StackStack {
|
||||||
var ss = std.ArrayList(stack.Stack).init(allocator);
|
var ss = std.ArrayList(stack.Stack).init(allocator);
|
||||||
errdefer ss.deinit();
|
errdefer ss.deinit();
|
||||||
var toss = try ss.addOne();
|
var s = try ss.addOne();
|
||||||
toss.* = stack.Stack.init(allocator);
|
s.* = stack.Stack.init(allocator);
|
||||||
return StackStack{
|
return StackStack{
|
||||||
.data = ss,
|
.data = ss,
|
||||||
.toss = toss,
|
.toss = s,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
pub fn pop(self: *StackStack) i64 {
|
pub inline fn toss(self: *StackStack) *stack.Stack {
|
||||||
return self.toss.*.pop();
|
return self.toss;
|
||||||
}
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue