SOLA
Loading...
Searching...
No Matches
tree_helper.h
1// Copyright The SOLA Contributors
2//
3// Licensed under the MIT License.
4// For details on the licensing terms, see the LICENSE file.
5// SPDX-License-Identifier: MIT
6
7#ifndef NATTER_UTILS_TREE_HELPER_H_
8#define NATTER_UTILS_TREE_HELPER_H_
9
10#include <cassert>
11#include <cstdint>
12#include <set>
13#include <string>
14
15#include "natter/minhcast_level_number.h"
16
17namespace natter::minhcast {
18
26constexpr bool childFromNode(LevelNumber own_node, LevelNumber initial_node) {
27 const auto [own_level, own_number, fanout] = own_node;
28 const auto [initial_level, initial_number, initial_fanout] = initial_node;
29 assert(fanout == initial_fanout);
30 uint32_t parent = own_number;
31 if (own_level <= initial_level) return false;
32 for (uint32_t current_level = own_level; current_level > initial_level; current_level--) {
33 parent = parent / fanout;
34 if ((current_level - 1) == initial_level && parent == initial_number) return true;
35 }
36 return false;
37}
38
44std::set<LevelNumber> calculateRRT(LevelNumber node);
45
51std::set<LevelNumber> calculateLRT(LevelNumber node);
52
53std::string toLevelNumberPair(LevelNumber node);
54LevelNumber fromStringToLevelNumber(const std::string &node);
55} // namespace natter::minhcast
56
57#endif // DAISI_TREE_HELPER_H_