triskele/include/Tree.tpp
Git Merciol e5643b9d54 nouveau fichier : include/ArrayTree/GraphWalker.tpp
nouveau fichier : include/ArrayTree/Leader.tpp
	nouveau fichier : include/ArrayTree/triskeleArrayTreeBase.tpp
	nouveau fichier : include/Tree.tpp
	nouveau fichier : src/triskeleBase.cpp
2017-11-28 04:32:46 +01:00

28 lines
842 B
C++

#ifndef _OTB_TRISKELE_TREE_TPP
#define _OTB_TRISKELE_TREE_TPP
template<typename FuncToApply>
void
Tree::forEachLeaf (const FuncToApply &f /* f (DimNodeId leafId) */) const {
for (DimNodeId leafId = 0; leafId < leafCount; ++leafId)
f (leafId);
}
template<typename FuncToApply>
void
Tree::forEachComp (const FuncToApply &f /* f (DimNodeId compId) */) const {
DimNodeId compCount = nodeCount - leafCount;
for (DimNodeId compId = 0; compId < compCount; ++compId)
f (compId);
}
template<typename FuncToApply>
void
Tree::forEachChild (const DimNodeId &parentId, const FuncToApply &f /* f (DimNodeId childId) */) const {
DimNodeId minChild = childCount[parentId], maxChild = childCount[parentId+1];
for (DimNodeId childId = minChild; childId < maxChild; ++childId)
f (children[childId]);
}
#endif // _OTB_TRISKELE_TREE_TPP