本文整理汇总了C++中tree::end方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::end方法的具体用法?C++ tree::end怎么用?C++ tree::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateSubTree
/*!
* \fn static bool GenerateSubTree(const tree<HTML::Node> &tDom, const string &tagname, tree<HTML::Node> &tSubDom);
* \brief 生成子树
* \param [in]DOM原树
* \param [in]子树根节点的标签名
* \param [out]DOM子树
* \return bool
* \date 2011-06-01
* \author nanjunxiao
*/
bool Pretreat::GenerateSubTree(const tree<HTML::Node> &tDom, const std::string &tagname, tree<HTML::Node> &tSubDom)//目前只是为body使用
{
tree<HTML::Node>::iterator tIter = tDom.begin();
tree<HTML::Node>::sibling_iterator tFromIter,tToIter;
string sTagName;
for (; tIter != tDom.end(); ++tIter)
{
/*if (tIter->tagName() == tagname)
break;*/
if (tIter->isTag() )
{
sTagName = tIter->tagName();
transform(sTagName.begin(), sTagName.end(), sTagName.begin(), ::tolower);
if (sTagName == tagname)
break;
}
}
if (tIter == tDom.end() )
{
return false;
}
tFromIter = tIter;
tToIter = tDom.next_sibling(tFromIter);
tDom.subtree(tSubDom, tFromIter, tToIter);
return true;
}
示例2: print_subtree_bracketed
void print_subtree_bracketed(const tree<T>& t, typename tree<T>::iterator iRoot, std::ostream& str)
{
if(t.begin() == t.end()) return;
if (t.number_of_children(iRoot) == 0) {
str << *iRoot;
}
else {
// parent
str << *iRoot;
str << "(";
// child1, ..., childn
int siblingCount = t.number_of_siblings(t.begin(iRoot));
int siblingNum;
typename tree<T>::sibling_iterator iChildren;
for (iChildren = t.begin(iRoot), siblingNum = 0; iChildren != t.end(iRoot); ++iChildren, ++siblingNum) {
// recursively print child
print_subtree_bracketed(t,iChildren,str);
// comma after every child except the last one
if (siblingNum != siblingCount - 1 ) {
str << ", ";
}
}
str << ")";
}
}
示例3: T
// -----------------------------------------------------------------
// Hace que el valor de un nod interior sea el resultado de aplicar
// la funcion asociativa a los hijos, es decir
// `*n = afun(init_val,s_1,s_2,...,s_m)',
// donde `s_j' son los hijos de `n'
template<class T> void
reduce_up (tree<T> & Q, typename tree<T>::iterator n,
T (*afun) (T,T), T init_val) {
typename tree<T>::iterator c ;
T val ;
c = n.lchild();
if (c == Q.end()) return;
val = init_val;
while (c != Q.end()) {
reduce_up (Q, c, afun, init_val);
val = afun (val,*c);
c++;
}
*n = val;
}
示例4: writeSiblingsXML
void writeSiblingsXML(const tree<AstNode>& t, const tree<AstNode>::iterator iRoot, ostream& stream)
{
if(t.empty())
return;
if (iRoot->getType() == "root") {
tree<AstNode>::sibling_iterator iChildren = t.begin(iRoot);
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl;
writeSiblingsXML(t,iChildren,stream);
}
else if (t.number_of_children(iRoot) == 0) {
string type = iRoot->getType();
stream << "<php:" << type << '>';
if (iRoot->getValue().length() > 0)
stream << htmlentities(iRoot->getValue());
stream << "</php:" << type << '>' << endl;
}
else {
string type = iRoot->getType();
string xmlns="";
if (type == "start")
xmlns = " xmlns:php=\"http://php.net/csl\"";
stream << "<php:" << type << xmlns << '>' << endl;
int siblingNum;
tree<AstNode>::sibling_iterator iChildren;
for (iChildren = t.begin(iRoot), siblingNum = 0; iChildren != t.end(iRoot); ++iChildren)
{
writeSiblingsXML(t,iChildren,stream);
}
stream << "</php:" << type << '>' << endl;
}
}
示例5: findNodeWithPathFromNode
tree_node_<FILE_ITEM>* CFileTree::findNodeWithPathFromNode(std::string path, tree_node_<FILE_ITEM>* node)
{
tree<FILE_ITEM>::sibling_iterator sib = filesTree.begin(node);
tree<FILE_ITEM>::sibling_iterator end = filesTree.end(node);
bool currentLevel = true;
std::string currentPath = _first_dirname(path);
size_t position = currentPath.size();
std::string followingPath = _following_path(path);
currentLevel = followingPath.empty();
while (sib != end) {
// printf("sib->path '%s' lv %d curpath '%s' follow '%s'\n", sib->path, currentLevel, currentPath.c_str(), followingPath.c_str());
if (strcmp(sib->path, currentPath.c_str()) == 0) {
if (currentLevel) {
return sib.node;
}
else {
return findNodeWithPathFromNode(followingPath, sib.node);
}
}
++sib;
}
return NULL;
}
示例6: list_if
int list_if(tree<int> &T,
list<int> &L,
bool (*pred)(int)) {
L.clear();
if (T.begin()!=T.end())
list_if(T,T.begin(),L,pred);
}
示例7: apply
void apply (tree<T> & Q, typename tree<T>::iterator n,
T (*f) (T)) {
typename tree<T>::iterator c ;
*n = f (*n);
c = n.lchild ();
while (c != Q.end()) apply (Q, c++, f);
}
示例8: followingPath
tree_node_<FILE_ITEM>* CFileTree::findNodeWithPathFromNode(std::string path, tree_node_<FILE_ITEM>* node)
{
tree<FILE_ITEM>::sibling_iterator sib = filesTree.begin(node);
tree<FILE_ITEM>::sibling_iterator end = filesTree.end(node);
bool currentLevel = true;
std::string currentPath = path.substr(0, path.find('\\'));
size_t position = path.find('\\');
std::string followingPath("");
if (position != std::string::npos) {
followingPath = path.substr(path.find('\\') + 1);
currentLevel = false;
}
while (sib != end) {
if (strcmp(sib->path, currentPath.c_str()) == 0) {
if (currentLevel) {
return sib.node;
}
else {
return findNodeWithPathFromNode(followingPath, sib.node);
}
}
++sib;
}
return NULL;
}
示例9: while
//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*>---:---<*>---:
void tree2list(tree &A,iterator_t n,
list<elem_t> &L,elem_t BP,elem_t EP) {
if (n == A.end()) return;
iterator_t c = n.lchild();
if (c == A.end()) {
L.insert(L.end(),A.retrieve(n));
} else {
L.insert(L.end(),BP);
L.insert(L.end(),A.retrieve(n));
while (c != A.end()) {
tree2list(A,c,L,BP,EP);
c = c.right();
}
L.insert(L.end(),EP);
}
}
示例10: all
bool all (tree<T> &Q,typename tree<T>::iterator n,
bool (*pred_fun)(T j)) {
if (!pred_fun(*n)) return false;
typename tree<T>::iterator c = n.lchild();
while (c!=Q.end()) if (!pred_fun(*c++)) return false;
return true;
}
示例11: operator
void RenameClass::operator()(tree<AstNode>& tr, MapClasses* classes, MapVariables* vars, MapFunctions *func) {
// for every names in the class, generate a new *unique* name
map<string, string> classNames;
for (MapClasses::iterator iter = classes->begin(); iter != classes->end(); ++iter)
{
string newName = generateName();
classNames.insert(make_pair(iter->first, newName));
}
map<string, string>::iterator cter;
tree<AstNode>::iterator parent;
for (tree<AstNode>::iterator iter=tr.begin(); iter!=tr.end(); ++iter)
{
parent = tr.parent(iter);
if (iter->getType() == "text"
&& parent->getType() == "T_STRING"
&& (tr.parent(parent)->getType() == "unticked_class_declaration_statement"
|| tr.parent(parent)->getType() == "function_call" // constructor
|| tr.parent(parent)->getType() == "class_name_reference"
|| tr.parent(parent)->getType() == "fully_qualified_class_name"
)
&& ((cter=classNames.find(iter->getValue())) != classNames.end())) {
// rename the currenet node
iter->setValue(cter->second);
}
}
}
示例12: any
bool any (tree <T> & Q, typename tree<T>::iterator n,
bool (*pred_fun) (T)) {
typename tree<T>::iterator c ;
if ( pred_fun (*n) ) return true;
c = n.lchild ();
while (c != Q.end()) if (pred_fun (*c++)) return true;
return false;
}
示例13: count_if
//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*>
int count_if(tree<int> &T,tree<int>::iterator n,
bool (*pred)(int)) {
int count = pred(*n);
tree<int>::iterator c = n.lchild();
while (c!=T.end())
count += count_if(T,c++,pred);
return count;
}
示例14: detectAfterStmt
bool detectAfterStmt(const tree<AstNode>& tr) {
unsigned short ret = 0;
for (tree<AstNode>::iterator iter=tr.begin(); iter!=tr.end(); ++iter) {
if (iter->getType() == "text" && iter->getValue() == "$__END_OBF_HERE") {
return true;
}
}
return false;
}
示例15: clean_pattern
/**
Clean the possible patterns annotations:
$enter_new_statement ...
*/
void clean_pattern(tree<AstNode>& tr) {
for (tree<AstNode>::iterator iter=tr.begin(); iter!=tr.end(); ++iter) {
if (iter->getType() == "text" && iter->getValue() == "$enter_the_new_statement") {
iter = rewind(iter, "statement", tr);
tr.erase(iter);
break;
}
}
}