triskele/include/Tree.tpp
Git Merciol bdd6110787 modifié : ../include/ArrayTree/ArrayTreeBuilder.hpp
modifié :         ../include/ArrayTree/ArrayTreeBuilder.tpp
	modifié :         ../include/ArrayTree/GraphWalker.hpp
	modifié :         ../include/ArrayTree/GraphWalker.tpp
	modifié :         ../include/ArrayTree/Leader.tpp
	modifié :         ../include/IImage.tpp
	modifié :         ../include/Tree.hpp
	modifié :         ../include/Tree.tpp
	modifié :         ../include/TreeBuilder.hpp
	modifié :         ../include/TreeBuilder.tpp
	modifié :         ../src/QuadTree/QuadTreeBuilder.cpp
	modifié :         ../src/Tree.cpp
	modifié :         ../src/XMLTree/XMLTreeBuilder.cpp
	modifié :         ../src/testMain.cpp
2018-02-18 11:19:40 +01:00

91 lines
2.0 KiB
C++

#ifndef _OTB_TRISKELE_TREE_TPP
#define _OTB_TRISKELE_TREE_TPP
inline DimNodeId *
Tree::getChildCount () {
return childCount;
}
inline void
Tree::setNodeCount (const DimImg &newNodeCount) {
nodeCount = newNodeCount;
}
inline void
Tree::setSize (const Size &newSize) {
size = newSize;
}
inline State
Tree::getState () const {
return state;
}
inline Size
Tree::getSize () const {
return size;
}
inline DimNodeId
Tree::getRoot () const {
return nodeCount-1;
}
inline DimNodeId
Tree::getAbsRoot () const {
return nodeCount-1+leafCount;
}
inline DimNodeId
Tree::getCompCount () const {
return nodeCount-leafCount;
}
inline const DimNodeId &
Tree::getParent (const DimNodeId &idx) const {
return leafParents[idx];
}
inline const DimNodeId &
Tree::getLeafParent (const DimNodeId &idx) const {
return leafParents[idx];
}
inline const DimNodeId &
Tree::getCompParent (const DimNodeId &idx) const {
return compParents[idx];
}
inline const DimNodeId &
Tree::getChildrenCount (const DimImg &idx) const {
return childCount[idx];
}
inline const DimSideImg &
Tree::getLeafCount () const {
return leafCount;
}
inline const DimSideImg &
Tree::getNodeCount () const {
return nodeCount;
}
template<typename FuncToApply>
inline void
Tree::forEachLeaf (const FuncToApply &f /* f (DimNodeId leafId) */) const {
for (DimNodeId leafId = 0; leafId < leafCount; ++leafId)
f (leafId);
}
template<typename FuncToApply>
inline 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>
inline 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