Loading [MathJax]/extensions/tex2jax.js
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
traversal_node.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024-2025, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 #include <cstddef>
18 #include <exception>
19 #include <string>
20 
21 namespace ML {
22 namespace experimental {
23 namespace forest {
24 
26 struct parentless_node_exception : std::exception {
27  parentless_node_exception() : msg_{"Node does not track its parent"} {}
28  parentless_node_exception(std::string msg) : msg_{msg} {}
29  parentless_node_exception(char const* msg) : msg_{msg} {}
30  virtual char const* what() const noexcept { return msg_.c_str(); }
31 
32  private:
33  std::string msg_;
34 };
35 
36 template <typename id_t = std::size_t>
38  public:
39  using id_type = id_t;
40  virtual bool is_leaf() const = 0;
41  virtual id_type hot_child() const = 0;
42  virtual id_type distant_child() const = 0;
43  virtual id_type parent() const
44  {
46  return id_type{};
47  }
48 };
49 
50 } // namespace forest
51 } // namespace experimental
52 } // namespace ML
Definition: dbscan.hpp:30
parentless_node_exception()
Definition: traversal_node.hpp:27
parentless_node_exception(std::string msg)
Definition: traversal_node.hpp:28
parentless_node_exception(char const *msg)
Definition: traversal_node.hpp:29
virtual char const * what() const noexcept
Definition: traversal_node.hpp:30
Definition: traversal_node.hpp:37
virtual id_type distant_child() const =0
id_t id_type
Definition: traversal_node.hpp:39
virtual id_type hot_child() const =0
virtual id_type parent() const
Definition: traversal_node.hpp:43