aboutsummaryrefslogtreecommitdiff
path: root/src/view_stack.zig
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-04-04 16:26:13 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2020-04-04 16:51:14 +0200
commit424a16fe94b01b322aa61a8f07a97c1a98431638 (patch)
treec3da7a165c7ccac7f19efbe7d8063c4c42c8853e /src/view_stack.zig
parent6c8e7c14f7f2cb76c1e4e0ea60dfa2c0433c6c94 (diff)
downloadriver-424a16fe94b01b322aa61a8f07a97c1a98431638.tar.gz
river-424a16fe94b01b322aa61a8f07a97c1a98431638.tar.xz
Remove len field from ViewStack
This is misleading as unmapped views should be ignored
Diffstat (limited to 'src/view_stack.zig')
-rw-r--r--src/view_stack.zig17
1 files changed, 1 insertions, 16 deletions
diff --git a/src/view_stack.zig b/src/view_stack.zig
index 824dac3..a729837 100644
--- a/src/view_stack.zig
+++ b/src/view_stack.zig
@@ -18,14 +18,10 @@ pub const ViewStack = struct {
first: ?*Node,
last: ?*Node,
- /// Total number of views
- len: u32,
-
/// Initialize an undefined stack
pub fn init(self: *Self) void {
self.first = null;
self.last = null;
- self.len = 0;
}
/// Add a node to the top of the stack.
@@ -43,9 +39,8 @@ pub const ViewStack = struct {
self.last = new_node;
}
- // Set the first pointer to the new node and increment length
+ // Set the first pointer to the new node
self.first = new_node;
- self.len += 1;
}
/// Remove a node from the view stack. This removes it from the stack of
@@ -64,8 +59,6 @@ pub const ViewStack = struct {
} else {
self.last = target_node.prev;
}
-
- self.len -= 1;
}
const Iterator = struct {
@@ -151,13 +144,11 @@ test "push/remove" {
const five = try allocator.create(ViewStack.Node);
defer allocator.destroy(five);
- testing.expect(views.len == 0);
views.push(three); // {3}
views.push(one); // {1, 3}
views.push(four); // {4, 1, 3}
views.push(five); // {5, 4, 1, 3}
views.push(two); // {2, 5, 4, 1, 3}
- testing.expect(views.len == 5);
// Simple insertion
{
@@ -174,7 +165,6 @@ test "push/remove" {
it = it.?.next;
testing.expect(it == null);
- testing.expect(views.len == 5);
testing.expect(views.first == two);
testing.expect(views.last == three);
@@ -194,7 +184,6 @@ test "push/remove" {
it = it.?.next;
testing.expect(it == null);
- testing.expect(views.len == 4);
testing.expect(views.first == five);
testing.expect(views.last == three);
@@ -212,7 +201,6 @@ test "push/remove" {
it = it.?.next;
testing.expect(it == null);
- testing.expect(views.len == 3);
testing.expect(views.first == five);
testing.expect(views.last == one);
@@ -228,7 +216,6 @@ test "push/remove" {
it = it.?.next;
testing.expect(it == null);
- testing.expect(views.len == 2);
testing.expect(views.first == five);
testing.expect(views.last == one);
@@ -252,7 +239,6 @@ test "push/remove" {
it = it.?.next;
testing.expect(it == null);
- testing.expect(views.len == 5);
testing.expect(views.first == four);
testing.expect(views.last == one);
@@ -267,7 +253,6 @@ test "push/remove" {
testing.expect(views.first == null);
testing.expect(views.last == null);
- testing.expect(views.len == 0);
}
test "iteration" {