diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-07-26 02:55:58 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-07-26 02:55:58 +0100 |
commit | 139f2e9e5a6db38095f9ba4b006e5867e251458e (patch) | |
tree | adb69713ff7b2690df120ddf17f8cf73a55a2006 | |
parent | d73ecff38a9894c226c5de63a1b3ff2b4f1a9f2d (diff) | |
download | cw_tree-139f2e9e5a6db38095f9ba4b006e5867e251458e.tar.gz cw_tree-139f2e9e5a6db38095f9ba4b006e5867e251458e.tar.bz2 cw_tree-139f2e9e5a6db38095f9ba4b006e5867e251458e.zip |
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.
-rw-r--r-- | src/numerics.hpp | 6 |
1 files 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<word_t> queue, NodeAllocator &allocator); +void iterate(std::queue<word_t> &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 |