Created
May 21, 2010 02:30
-
-
Save allen501pc/408383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Class: CAlgo | |
* T : type of "Node" , with begin() , end() and operator++ | |
* ClassC1 : the implemented class , must have operator() | |
*/ | |
template<typename T,typename ClassC1 > | |
class CAlgo : public ClassC1 | |
{ | |
protected: | |
void DFS(T * ptrNode, ClassC1 *ptrObj ) | |
{ | |
(*ptrObj)(); | |
for( T * ptrTempNode = ptrNode->begin(); ptrTempNode != ptrNode->end(); ++ ptrTempNode ) | |
{ | |
DFS(ptrTempNode, ptrObj); | |
} | |
} | |
public: | |
void DFSbyRoot(T * ptrNode, ClassC1 *ptrObj) | |
{ | |
for( T * ptrTempNode = ptrNode->begin(); ptrTempNode != ptrNode->end(); ++ ptrTempNode ) | |
{ | |
DFS(ptrTempNode, ptrObj); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment