Belle II Software development
WeightedParititioningDynTree< T, ADomain, ADomainDivsion > Class Template Reference

Type of tree for partitioning the hough space. More...

#include <WeightedFastHoughTree.h>

Inheritance diagram for WeightedParititioningDynTree< T, ADomain, ADomainDivsion >:
DynTree< WithWeightedItems< ADomain, T >, ADomainDivsion >

Public Member Functions

 WeightedParititioningDynTree (ADomain topDomain, ADomainDivsion domainDivsion)
 Constructor attaching a vector of the weighted items to the top most node domain.
 
Node & getTopNode ()
 Getter for the top node of the tree.
 
const Node & getTopNode () const
 Constant getter for the top node of the tree.
 
int getNNodes () const
 Gets the number of nodes currently contained in the tree Also demonstrates how to walk over the tree.
 
std::map< int, int > getNNodesByLevel () const
 Gets the number of nodes by level in the tree Also demonstrates how to walk over the tree.
 
void walk (AWalker &walker)
 Forward walk to the top node.
 
void walk (AWalker &walker, APriorityMeasure &priority)
 Forward walk to the top node.
 
void fell ()
 Fell to tree meaning deleting all child nodes from the tree. Keeps the top node.
 
void raze ()
 Like fell but also releases all memory the tree has acquired during long execution.
 

Public Attributes

SubPropertiesFactory m_subPropertiesFactory
 Instance of the properties factory for the sub nodes.
 
Node m_topNode
 Memory for the top node of the tree.
 
std::deque< typename Node::Children > m_children
 Central point to provide memory for the child structures.
 
size_t m_nUsedChildren
 Last index of used children.
 

Private Types

using Super = DynTree< WithWeightedItems< ADomain, T >, ADomainDivsion >
 Type of the base class.
 
using This = DynTree< WithWeightedItems< ADomain, T >, ADomainDivsion >
 Type of this class.
 
using Properties = WithWeightedItems< ADomain, T >
 Type of the Properties.
 
using SubPropertiesFactory = ADomainDivsion
 Type of the factory for the sub node properties.
 

Private Member Functions

std::vector< Node > * createChildren (Node *parentNode)
 Create child nodes for the given parents.
 
std::vector< Node > * getUnusedChildren ()
 Acquire the next unused child node structure, recycling all memory.
 

Detailed Description

template<class T, class ADomain, class ADomainDivsion>
class Belle2::TrackFindingCDC::WeightedParititioningDynTree< T, ADomain, ADomainDivsion >

Type of tree for partitioning the hough space.

Definition at line 29 of file WeightedFastHoughTree.h.

Member Typedef Documentation

◆ Properties

using Properties = WithWeightedItems< ADomain, T >
privateinherited

Type of the Properties.

Definition at line 41 of file DynTree.h.

◆ SubPropertiesFactory

using SubPropertiesFactory = ADomainDivsion
privateinherited

Type of the factory for the sub node properties.

Definition at line 44 of file DynTree.h.

◆ Super

using Super = DynTree< WithWeightedItems<ADomain, T>, ADomainDivsion>
private

Type of the base class.

Definition at line 33 of file WeightedFastHoughTree.h.

◆ This

using This = DynTree<WithWeightedItems< ADomain, T > , ADomainDivsion >
privateinherited

Type of this class.

Definition at line 38 of file DynTree.h.

Constructor & Destructor Documentation

◆ WeightedParititioningDynTree()

WeightedParititioningDynTree ( ADomain  topDomain,
ADomainDivsion  domainDivsion 
)
inline

Constructor attaching a vector of the weighted items to the top most node domain.

Definition at line 37 of file WeightedFastHoughTree.h.

37 :
38 Super(WithWeightedItems<ADomain, T>(std::move(topDomain)), std::move(domainDivsion))
39 {}
DynTree< WithWeightedItems< ADomain, T >, ADomainDivsion > Super
Type of the base class.

Member Function Documentation

◆ createChildren()

std::vector< Node > * createChildren ( Node *  parentNode)
inlineprivateinherited

Create child nodes for the given parents.

Definition at line 284 of file DynTree.h.

285 {
286 std::vector<Node>* result = getUnusedChildren();
287 auto subProperties = m_subPropertiesFactory(*parentNode);
288 if (subProperties.empty()) {
289 result->clear();
290 } else {
291 // Initialize new elements with dummy property.
292 result->resize(subProperties.size(), Node(subProperties.back()));
293 size_t iSubNode = 0;
294 for (auto& properties : subProperties) {
295 clearIfApplicable(result->at(iSubNode));
296 result->at(iSubNode) = properties;
297 ++iSubNode;
298 }
299 }
300 return result;
301 }
std::vector< Node > * getUnusedChildren()
Acquire the next unused child node structure, recycling all memory.
Definition: DynTree.h:304
SubPropertiesFactory m_subPropertiesFactory
Instance of the properties factory for the sub nodes.
Definition: DynTree.h:358

◆ fell()

void fell ( )
inlineinherited

Fell to tree meaning deleting all child nodes from the tree. Keeps the top node.

Definition at line 334 of file DynTree.h.

335 {
336 clearIfApplicable(m_topNode);
337 m_topNode.unlink();
338 m_topNode.m_tree = this;
339 for (typename Node::Children& children : m_children) {
340 for (Node& node : children) {
341 clearIfApplicable(node);
342 node.unlink();
343 }
344 }
345 m_nUsedChildren = 0;
346 }

◆ getNNodes()

int getNNodes ( ) const
inlineinherited

Gets the number of nodes currently contained in the tree Also demonstrates how to walk over the tree.

Definition at line 248 of file DynTree.h.

249 {
250 int nNodes = 0;
251 auto countNodes = [&nNodes](const Node*) -> bool {
252 ++nNodes;
253 return true;
254 };
255 const_cast<DynTree&>(*this).walk(countNodes);
256 //walk(countNodes);
257 return nNodes;
258 }
DynTree(const Properties &properties, const SubPropertiesFactory &subPropertiesFactory=SubPropertiesFactory())
Constructor taking properties with which the top node of the tree is initialised.
Definition: DynTree.h:221

◆ getNNodesByLevel()

std::map< int, int > getNNodesByLevel ( ) const
inlineinherited

Gets the number of nodes by level in the tree Also demonstrates how to walk over the tree.

Definition at line 264 of file DynTree.h.

265 {
266 std::map<int, int> nNodesByLevel;
267 auto countNodes = [&nNodesByLevel](const Node * node) -> bool {
268 if (nNodesByLevel.count(node->getLevel()) == 0)
269 {
270 nNodesByLevel[node->getLevel()] = 1;
271 } else
272 {
273 nNodesByLevel[node->getLevel()]++;
274 }
275 return true;
276 };
277 const_cast<DynTree&>(*this).walk(countNodes);
278 //walk(countNodes);
279 return nNodesByLevel;
280 }

◆ getTopNode() [1/2]

Node & getTopNode ( )
inlineinherited

Getter for the top node of the tree.

Definition at line 237 of file DynTree.h.

238 { return m_topNode; }

◆ getTopNode() [2/2]

const Node & getTopNode ( ) const
inlineinherited

Constant getter for the top node of the tree.

Definition at line 241 of file DynTree.h.

242 { return m_topNode; }

◆ getUnusedChildren()

std::vector< Node > * getUnusedChildren ( )
inlineprivateinherited

Acquire the next unused child node structure, recycling all memory.

Definition at line 304 of file DynTree.h.

305 {
306 if (m_nUsedChildren >= m_children.size()) {
307 m_children.emplace_back();
308 }
310 return &(m_children[m_nUsedChildren - 1]);
311 }
std::deque< typename Node::Children > m_children
Central point to provide memory for the child structures.
Definition: DynTree.h:364

◆ raze()

void raze ( )
inlineinherited

Like fell but also releases all memory the tree has acquired during long execution.

Definition at line 349 of file DynTree.h.

350 {
351 this->fell();
352 m_children.clear();
353 m_children.shrink_to_fit();
354 }
void fell()
Fell to tree meaning deleting all child nodes from the tree. Keeps the top node.
Definition: DynTree.h:334

◆ walk() [1/2]

void walk ( AWalker &  walker)
inlineinherited

Forward walk to the top node.

Definition at line 316 of file DynTree.h.

317 {
318 static_assert(std::is_assignable<std::function<bool(Node*)>, AWalker>(), "");
319
320 getTopNode().walk(walker);
321 }

◆ walk() [2/2]

void walk ( AWalker &  walker,
APriorityMeasure &  priority 
)
inlineinherited

Forward walk to the top node.

Definition at line 325 of file DynTree.h.

326 {
327 static_assert(std::is_assignable<std::function<bool(Node*)>, AWalker>(), "");
328 static_assert(std::is_assignable<std::function<float(Node*)>, APriorityMeasure>(), "");
329
330 getTopNode().walk(walker, priority);
331 }

Member Data Documentation

◆ m_children

std::deque<typename Node::Children> m_children
inherited

Central point to provide memory for the child structures.

Definition at line 364 of file DynTree.h.

◆ m_nUsedChildren

size_t m_nUsedChildren
inherited

Last index of used children.

Definition at line 367 of file DynTree.h.

◆ m_subPropertiesFactory

SubPropertiesFactory m_subPropertiesFactory
inherited

Instance of the properties factory for the sub nodes.

Definition at line 358 of file DynTree.h.

◆ m_topNode

Node m_topNode
inherited

Memory for the top node of the tree.

Definition at line 361 of file DynTree.h.


The documentation for this class was generated from the following file: