mlpack 3.4.2
x_tree_auxiliary_information.hpp
Go to the documentation of this file.
1
13#ifndef MLPACK_CORE_TREE_RECTANGLE_TREE_X_TREE_AUXILIARY_INFORMATION_HPP
14#define MLPACK_CORE_TREE_RECTANGLE_TREE_X_TREE_AUXILIARY_INFORMATION_HPP
15
16namespace mlpack {
17namespace tree {
18
23template<typename TreeType>
25{
26 public:
29 normalNodeMaxNumChildren(0),
30 splitHistory(0)
31 { };
32
38 XTreeAuxiliaryInformation(const TreeType* node) :
39 normalNodeMaxNumChildren(node->Parent() ?
40 node->Parent()->AuxiliaryInfo().NormalNodeMaxNumChildren() :
41 node->MaxNumChildren()),
42 splitHistory(node->Bound().Dim())
43 { };
44
55 TreeType* /* tree */ = NULL,
56 bool /* deepCopy */ = true) :
57 normalNodeMaxNumChildren(other.NormalNodeMaxNumChildren()),
58 splitHistory(other.SplitHistory())
59 { };
60
67 {
68 normalNodeMaxNumChildren = other.NormalNodeMaxNumChildren();
69 splitHistory = other.SplitHistory();
70
71 return *this;
72 }
73
80 normalNodeMaxNumChildren(other.NormalNodeMaxNumChildren()),
81 splitHistory(std::move(other.splitHistory))
82 {
83 other.normalNodeMaxNumChildren = 0;
84 };
85
96 bool HandlePointInsertion(TreeType* /* node */, const size_t /* point */)
97 {
98 return false;
99 }
100
113 bool HandleNodeInsertion(TreeType* /* node */,
114 TreeType* /* nodeToInsert */,
115 bool /* insertionLevel */)
116 {
117 return false;
118 }
119
129 bool HandlePointDeletion(TreeType* /* node */ , const size_t /* localIndex */)
130 {
131 return false;
132 }
133
143 bool HandleNodeRemoval(TreeType* /* node */ , const size_t /* nodeIndex */)
144 {
145 return false;
146 }
147
154 bool UpdateAuxiliaryInfo(TreeType* /* node */)
155 {
156 return false;
157 }
158
163 { }
164
169 typedef struct SplitHistoryStruct
170 {
172 std::vector<bool> history;
173
175 {
176 for (int i = 0; i < dim; ++i)
177 history[i] = false;
178 }
179
182 history(other.history)
183 { }
184
186 {
188 history = other.history;
189 return *this;
190 }
191
194 history(std::move(other.history))
195 {
196 other.lastDimension = 0;
197 }
198
199 template<typename Archive>
200 void serialize(Archive& ar, const unsigned int /* version */)
201 {
202 ar & BOOST_SERIALIZATION_NVP(lastDimension);
203 ar & BOOST_SERIALIZATION_NVP(history);
204 }
206
207 private:
209 size_t normalNodeMaxNumChildren;
211 SplitHistoryStruct splitHistory;
212
213 public:
215 size_t NormalNodeMaxNumChildren() const { return normalNodeMaxNumChildren; }
217 size_t& NormalNodeMaxNumChildren() { return normalNodeMaxNumChildren; }
219 const SplitHistoryStruct& SplitHistory() const { return splitHistory; }
221 SplitHistoryStruct& SplitHistory() { return splitHistory; }
222
226 template<typename Archive>
227 void serialize(Archive& ar, const unsigned int /* version */)
228 {
229 ar & BOOST_SERIALIZATION_NVP(normalNodeMaxNumChildren);
230 ar & BOOST_SERIALIZATION_NVP(splitHistory);
231 }
232};
233
234} // namespace tree
235} // namespace mlpack
236
237#endif // MLPACK_CORE_TREE_RECTANGLE_TREE_X_TREE_AUXILIARY_INFORMATION_HPP
The XTreeAuxiliaryInformation class provides information specific to X trees for each node in a Recta...
struct mlpack::tree::XTreeAuxiliaryInformation::SplitHistoryStruct SplitHistoryStruct
The X tree requires that the tree records it's "split history".
bool UpdateAuxiliaryInfo(TreeType *)
Some tree types require to propagate the information upward.
bool HandlePointDeletion(TreeType *, const size_t)
Some tree types require to save some properties at the deletion process.
bool HandleNodeInsertion(TreeType *, TreeType *, bool)
Some tree types require to save some properties at the insertion process.
XTreeAuxiliaryInformation & operator=(const XTreeAuxiliaryInformation &other)
Copy the auxiliary information object.
bool HandleNodeRemoval(TreeType *, const size_t)
Some tree types require to save some properties at the deletion process.
XTreeAuxiliaryInformation(XTreeAuxiliaryInformation &&other)
Create an auxiliary information object by moving from the other node.
XTreeAuxiliaryInformation(const XTreeAuxiliaryInformation &other, TreeType *=NULL, bool=true)
Create an auxiliary information object by copying from another object.
void NullifyData()
Nullify the auxiliary information in order to prevent an invalid free.
size_t NormalNodeMaxNumChildren() const
Return the maximum number of a normal node's children.
XTreeAuxiliaryInformation(const TreeType *node)
Construct this with the specified node.
SplitHistoryStruct & SplitHistory()
Modify the split history of the node associated with this object.
const SplitHistoryStruct & SplitHistory() const
Return the split history of the node associated with this object.
bool HandlePointInsertion(TreeType *, const size_t)
Some tree types require to save some properties at the insertion process.
void serialize(Archive &ar, const unsigned int)
Serialize the information.
size_t & NormalNodeMaxNumChildren()
Modify the maximum number of a normal node's children.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
Definition: prereqs.hpp:67
The X tree requires that the tree records it's "split history".
SplitHistoryStruct & operator=(const SplitHistoryStruct &other)