本文整理汇总了C++中tree类的典型用法代码示例。如果您正苦于以下问题:C++ tree类的具体用法?C++ tree怎么用?C++ tree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: transform
/*!
* \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;
}
开发者ID:nanjunxiao,项目名称:Arise,代码行数:37,代码来源:Pretreat.cpp
示例2: allsuff
//--------------------------------------------------
//get sufficients stats for all bottom nodes
void allsuff(std::vector<std::vector<double> >& X,
tree& x, xinfo& xi, dinfo& di, tree::npv& bnv,
std::vector<sinfo>& sv)
{
tree::tree_cp tbn; //the pointer to the bottom node for the current observations
size_t ni; //the index into vector of the current bottom node
double* xx = new double[di.n_cov];
double y; //current y
bnv.clear();
x.getbots(bnv);
typedef tree::npv::size_type bvsz;
bvsz nb = bnv.size();
sv.resize(nb);
std::map<tree::tree_cp,size_t> bnmap;
for(bvsz i=0;i!=bnv.size();i++) bnmap[bnv[i]]=i;
for(size_t i=0;i<di.n_samp;i++) {
for(size_t j=0;j<di.n_cov; j++){
xx[j] = X[i][j];
}
y=di.y[i];
tbn = x.bn(xx,xi);
ni = bnmap[tbn];
++(sv[ni].n);
sv[ni].sy += y;
sv[ni].sy2 += y*y;
}
}
开发者ID:cran,项目名称:mpbart,代码行数:35,代码来源:funs.cpp
示例3: 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;
}
开发者ID:CandoImage,项目名称:winnfsd,代码行数:27,代码来源:FileTree.cpp
示例4: fillAllNodesNames
void fillAllNodesNames(Vstring& Vnames,const tree& tr){
vector<tree::nodeP> vAllNodes;
tr.getAllNodes(vAllNodes,tr.getRoot());
Vnames.resize(vAllNodes.size());
for (int i = 0; i<vAllNodes.size();++i)
Vnames[vAllNodes[i]->id()] = vAllNodes[i]->name();
}
开发者ID:AidanDelaney,项目名称:fastml,代码行数:7,代码来源:treeUtil.cpp
示例5: strcpy_s
FILE_ITEM CFileTree::AddItem(char *absolutePath, unsigned char* handle)
{
FILE_ITEM item;
item.handle = handle;
item.bCached = false;
if (filesTree.empty()) {
item.path = new char[strlen(absolutePath) + 1];
strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
item.nPathLen = strlen(item.path);
filesTree.set_head(item);
topNode = filesTree.begin();
}
else {
std::string sPath(absolutePath);
tree_node_<FILE_ITEM>* parentNode = findParentNodeFromRootForPath(absolutePath);
std::string splittedPath = sPath.substr(sPath.find_last_of('\\') + 1);
item.path = new char[splittedPath.length() + 1];
strcpy_s(item.path, (splittedPath.length() + 1), splittedPath.c_str());
if (parentNode) {
filesTree.append_child(tree<FILE_ITEM>::iterator_base(parentNode), item);
} else {
//printf("Parent node found for %s", absolutePath);
}
}
DisplayTree(topNode.node, 0);
return item;
}
开发者ID:CandoImage,项目名称:winnfsd,代码行数:31,代码来源:FileTree.cpp
示例6: build_tree
void build_tree(int L, int R) {
if(L == R) return;
int mid = (L + R)/2;
left = new tree; left->build_tree(L, mid);
right = new tree; right->build_tree(mid + 1, R);
}
开发者ID:sampritipanda,项目名称:IOI_Repository,代码行数:7,代码来源:METEORS.cpp
示例7: 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);
}
开发者ID:Malows,项目名称:aedcode,代码行数:7,代码来源:countif.cpp
示例8: 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;
}
}
开发者ID:laiello,项目名称:php-oracle,代码行数:31,代码来源:AstContainer.cpp
示例9: 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;
}
开发者ID:abymmathew,项目名称:winnfsd,代码行数:26,代码来源:FileTree.cpp
示例10: treeToJava
void treeToJava(JNIEnv * env, const tree<J_NVItem>::iterator_base & it, jobject & jnode, const JMultiTreeNode & fields)
{
// LOGI("Enter %s %p\n",__FUNCTION__,&it);
//转换当前节点
fields.cpp2Java(env, *it, jnode);
//处理子节点
tree<J_NVItem>::children_iterator itc = it.begin_children_iterator();
tree<J_NVItem>::children_iterator eitc = it.end_children_iterator();
//jclass clsNode = env->FindClass(JCLSNAME_TreeNode);
jclass clsArrayList = env->FindClass(JCLSNAME_ArrayList);
jmethodID add_mid = env->GetMethodID(clsArrayList,"add","(Ljava/lang/Object;)Z");
//当前节点孩子列表
jobject childList = env->GetObjectField(jnode, fields.m_Childs_id);
while(itc != eitc)
{
//创建java子节点
jobject jchild = env->NewObject(gClsTreeNode, fields.m_Construct_mid);
//转换子节点
treeToJava(env, itc, jchild, fields);
//添加子节点到当前节点孩子列表
env->CallBooleanMethod(childList, add_mid, jchild);
env->DeleteLocalRef(jchild);
++itc;
}
env->DeleteLocalRef((jobject)clsArrayList);
env->DeleteLocalRef(childList);
// LOGI("Leave %s %p\n",__FUNCTION__, &it);
}
开发者ID:cg8530,项目名称:WorkSplace,代码行数:32,代码来源:JniCaInterface.cpp
示例11: 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;
}
开发者ID:Malows,项目名称:aedcode,代码行数:9,代码来源:countif.cpp
示例12: WeaveNet
void WeaveNet(SQcont<T> const &incont, tree<T> &outnet)
{
outnet.clear();
auto top(outnet.begin());
auto now(outnet.insert(top, *incont.cbegin()));
for(auto c = incont.cbegin()+1;c != incont.cend();++c)
now = outnet.append_child(now, *c);
}
开发者ID:msaitow,项目名称:Femto2,代码行数:8,代码来源:SQnetwork.hpp
示例13: GenerateSubTree
/*!
* \fn static void GenerateSubTree(const tree<HTML::Node> &tDom, const tree<HTML::Node>::iterator &tIter, tree<HTML::Node> &tSubDom);
* \brief 生成子树
* \param [in]DOM原树
* \param [in]子树根节点的迭代器
* \param [out]DOM子树
* \return void
* \date 2011-06-01
* \author nanjunxiao
*/
void Pretreat::GenerateSubTree(const tree<HTML::Node> &tDom, const tree<HTML::Node>::iterator &tIter, tree<HTML::Node> &tSubDom)
{
tree<HTML::Node>::sibling_iterator tFromIter,tToIter;
tFromIter = tIter;
tToIter = tDom.next_sibling(tFromIter);
tDom.subtree(tSubDom, tFromIter, tToIter);
}
开发者ID:nanjunxiao,项目名称:Arise,代码行数:18,代码来源:Pretreat.cpp
示例14: 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;
}
}
}
开发者ID:laiello,项目名称:php-oracle,代码行数:13,代码来源:Obfuscator.cpp
示例15: 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;
}
开发者ID:laiello,项目名称:php-oracle,代码行数:9,代码来源:Obfuscator.cpp
示例16: getSequencesNames
vector<string> getSequencesNames(const tree& t){
vector<tree::nodeP> vleaves;
t.getAllLeaves(vleaves,t.getRoot());
vector<string> res;
vector<tree::nodeP>::const_iterator i = vleaves.begin();
for ( ; i<vleaves.end(); ++i) {
res.push_back((*i)->name());
}
return res;
}
开发者ID:AidanDelaney,项目名称:fastml,代码行数:10,代码来源:treeUtil.cpp
示例17: insert
void insert(int v){
if(v < value){
if(left) left->insert(v);
else left = new tree(v);
}
else{
if(right) right->insert(v);
else right = new tree(v);
}
}
开发者ID:joseleite19,项目名称:competitive-programming,代码行数:10,代码来源:C.cpp
示例18: treeHeight
int treeHeight(tree<int> t) {
if (t.empty()) {
return 0;
}
int leftTreeHeight = treeHeight(t.LeftTree());
int rightTreeHeight = treeHeight(t.RightTree());
return 1 + max(leftTreeHeight, rightTreeHeight);
}
开发者ID:stefolog,项目名称:fmi-sdp2015,代码行数:10,代码来源:treeproblems.cpp
示例19: evaluateOpFunc
//
//
// calculates expressions stored in a parse Tree
//
//
int evaluateOpFunc(opNode* exp, tree& symbolTable, tree& localVar, funcS& funcTable){
int rights;
int lefts ;
String s = exp->stringOp();
if(s == "NONE"){
return exp->val();
}else if(isValidVarName(s)){// if s is not an operation
if(s == "call"){
exp = exp->leftNode();
String funcName = exp->stringOp();// gets function name
param* parameter;
if(funcTable.isMember(funcName)){
parameter = funcTable.getParameters(funcName);// passing arguments
}else{
printf("WARNING: Function %s is not declared \n", funcName.c_str());
return 0;
}
int i = 0;
opNode* params = exp->leftNode();
if(params->stringOp() != "Ecall"){
while(params->stringOp() != "Ecall"){
parameter->op[i].value = evaluateOpFunc(params->rightNode(), symbolTable, localVar, funcTable);
params = params->leftNode();
i += 1;
}
}
tree* newTree = new tree;
for(int j =0; j < i ; j+=1){
newTree->insert(parameter->op[j].para, parameter->op[j].value);
}
if(funcTable.isMember(funcName)){
funcTable.addLocalVar(funcName, newTree);
evaluateFunc(funcName, symbolTable, funcTable);
return funcTable.getVal(funcName);
}else{
printf("Warning: function %s is not declared \n", funcName.c_str());
}
}
if(localVar.isMember(s)){
return localVar.getVal(s);
}else if(symbolTable.isMember(s)){
return symbolTable.getVal(s);
}
}
if(exp->leftNode()){
lefts = evaluateOpFunc(exp->leftNode(), symbolTable, localVar, funcTable);
if(s == "~" || s == "!"){return result(s, lefts, rights);}
}
if(exp->rightNode()){
rights = evaluateOpFunc(exp->rightNode(), symbolTable, localVar, funcTable);
}
return result(s,lefts,rights);
}
开发者ID:fanifish,项目名称:Blip-Interpreter,代码行数:60,代码来源:Source.cpp
示例20: countEdges
int countEdges(tree<T> t)
{
if (t.empty())
{
return 0;
}
else
{
return 1 + countEdges(t.leftTree()) + countEdges(t.rightTree());
}
}
开发者ID:stefolog,项目名称:fmi-sdp2015-test2,代码行数:11,代码来源:zad2_fn81091.cpp
注:本文中的tree类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论