diff options
Diffstat (limited to 'src/gss.zig')
| -rw-r--r-- | src/gss.zig | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gss.zig b/src/gss.zig index ef5d221..9201ca6 100644 --- a/src/gss.zig +++ b/src/gss.zig @@ -58,18 +58,22 @@ pub fn Graph(T: type) type { const Self = @This(); allocator: std.mem.Allocator, + number_of_nodes: usize = 0, + number_of_clones: usize = 0, pub fn init(allocator: std.mem.Allocator) Self { return Self { .allocator = allocator }; } pub fn push(self: *Self, node: *Node(T), state: T) !*Node(T) { + self.number_of_nodes += 1; const child = try self.allocator.create(Node(T)); child.* = try node.push(state); return child; } pub fn add_toplevel(self: *Self, state: T) !*Node(T) { + self.number_of_nodes += 1; const node = try self.allocator.create(Node(T)); node.* = try Node(T).init(state, self.allocator); node.is_toplevel = true; @@ -77,6 +81,8 @@ pub fn Graph(T: type) type { } pub fn clone(self: *Self, node: *Node(T), state: T) !*Node(T) { + self.number_of_nodes += 1; + self.number_of_clones += 1; const sibling = try self.allocator.create(Node(T)); sibling.* = try node.clone(state); return sibling; |