From 139f2e9e5a6db38095f9ba4b006e5867e251458e Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 26 Jul 2024 02:55:58 +0100 Subject: Rework node constructor and general procedure API Node constructor is now completely default constructed i.e. no constructor arguments required. The iterate function takes the queue by reference, so it can update the caller's state. Finally, to_string for a Node now uses the node allocator and an index to print out trees. Seems simpler and more in line with the current implementation. --- src/numerics.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/numerics.hpp b/src/numerics.hpp index be9d3db..c1317cd 100644 --- a/src/numerics.hpp +++ b/src/numerics.hpp @@ -41,7 +41,7 @@ struct Node Fraction value; int64_t left, right; - Node(Fraction val, int64_t left = -1, int64_t right = -1); + Node(Fraction val = {}, int64_t left = -1, int64_t right = -1); }; struct NodeAllocator @@ -53,9 +53,9 @@ struct NodeAllocator }; word_t gcd(word_t a, word_t b); -void iterate(std::queue queue, NodeAllocator &allocator); +void iterate(std::queue &queue, NodeAllocator &allocator); std::string to_string(const Fraction &); -std::string to_string(const Node &, int depth = 1); +std::string to_string(const NodeAllocator &, const word_t, int depth = 1); #endif -- cgit v1.2.3-13-gbd6f