diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-07-26 17:00:59 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-07-26 17:00:59 +0100 |
commit | 8cbc60279937adcd8edfcb12866cd56ecd1f1376 (patch) | |
tree | b231aa020a143215d919ccd74c6f209d50913567 /src/numerics.hpp | |
parent | c96c4630d54ce4bff1e6786b4c882c50505fea21 (diff) | |
download | cw_tree-8cbc60279937adcd8edfcb12866cd56ecd1f1376.tar.gz cw_tree-8cbc60279937adcd8edfcb12866cd56ecd1f1376.tar.bz2 cw_tree-8cbc60279937adcd8edfcb12866cd56ecd1f1376.zip |
Changed from int64_t to optional<word_t> for pointers in Node
Diffstat (limited to 'src/numerics.hpp')
-rw-r--r-- | src/numerics.hpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/numerics.hpp b/src/numerics.hpp index 9fdaf56..3d74202 100644 --- a/src/numerics.hpp +++ b/src/numerics.hpp @@ -19,6 +19,7 @@ #include <cstdint> +#include <optional> #include <queue> #include <string> #include <vector> @@ -26,6 +27,7 @@ #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define MAX(A, B) ((B) < (A) ? (A) : (B)) typedef uint64_t word_t; +typedef std::optional<word_t> index_t; struct Fraction { @@ -40,9 +42,10 @@ struct Fraction struct Node { Fraction value; - int64_t left, right; + index_t left, right; - Node(Fraction val = {}, int64_t left = -1, int64_t right = -1); + Node(Fraction val = {}, index_t left = std::nullopt, + index_t right = std::nullopt); }; struct NodeAllocator @@ -57,6 +60,6 @@ word_t gcd(word_t a, word_t b); Fraction iterate(std::queue<word_t> &queue, NodeAllocator &allocator); std::string to_string(const Fraction &); -std::string to_string(const NodeAllocator &, const word_t, int depth = 1); +std::string to_string(const NodeAllocator &, const index_t, int depth = 1); #endif |