void Profile::visit_node(Configuration* configuration, TiXmlNode* node, std::vector<std::string> variable) { if (node) { // visit the node only if it is one // first visit our siblings visit_node(configuration, node->NextSibling(), variable); // then check this element contains a // configuration variable TiXmlElement* element = node->ToElement(); if (element) { // append element name to variable to // build fully qualified variable name // before visit children variable.push_back(element->Value()); // if element contains text, we have a value for our // config variable, so add it to our configuration const char* text = element->GetText(); if (text) { configuration->insert (Variable::vector_to_string(variable), text); //std::cerr << "[Profile] Inserted variable: " << Variable::vector_to_string(variable) << " = " << text << std::endl; } } // then descend down the tree visit_node(configuration, node->FirstChild(), variable); } }
void default_visitor::visit_case_expression(case_expression_ast *node) { visit_node(node->expression); if (node->condition_sequence) { const list_node<case_condition_ast*> *__it = node->condition_sequence->to_front(), *__end = __it; do { visit_node(__it->element); __it = __it->next; } while (__it != __end); } }
void default_visitor::visit_feature(feature_ast *node) { if (node->formal_sequence) { const list_node<formal_ast*> *__it = node->formal_sequence->to_front(), *__end = __it; do { visit_node(__it->element); __it = __it->next; } while (__it != __end); } visit_node(node->expression); }
void default_visitor::visit_let_expression(let_expression_ast *node) { if (node->declaration_sequence) { const list_node<let_declaration_ast*> *__it = node->declaration_sequence->to_front(), *__end = __it; do { visit_node(__it->element); __it = __it->next; } while (__it != __end); } visit_node(node->body_expression); }
void default_visitor::visit_postfix_expression(postfix_expression_ast *node) { visit_node(node->base_expression); if (node->arguments_sequence) { const list_node<expression_ast*> *__it = node->arguments_sequence->to_front(), *__end = __it; do { visit_node(__it->element); __it = __it->next; } while (__it != __end); } }
void Inorder::obidji_lkd(VisualTreeElement* e){ if(e){ obidji_lkd(e->getLeft()); m_operations.push_back([=, this] () { emit highlightLine(3); QString order; // If animation is going forward: if (isGoingForward()) { if (e != getRoot()->nadji_minimum(getRoot(), 5000))//control coma (don't wanna : , first_reached) m_explanationText->setPlainText(QString(m_explanationText->toPlainText()) + ", "+ QString::number(e->getValue())); else m_explanationText->setPlainText(QString(m_explanationText->toPlainText()) + QString::number(e->getValue())); } // Animation going backward: else { order= m_explanationText->toPlainText(); if (e != getRoot()) order= order.mid(0, order.lastIndexOf(",")); else order= "Nodes are reached in order: "; m_explanationText->setPlainText(order); } visit_node(e); }); obidji_lkd(e->getRight()); } }
void inorder(BinNode* root) { if (root != nullptr) { inorder(root->left); visit_node(root); inorder(root->right); } }
void preorder(BinNode* root) { if (root != nullptr) { visit_node(root); preorder(root->left); preorder(root->right); } }
void postorder(BinNode* root) { if (root != nullptr) { postorder(root->left); postorder(root->right); visit_node(root); } }
void postOrder_traverse_binTree(biTNode_t *bTree) { if(bTree!=NULL && bTree->pLchild != NULL) preOrder_traverse_binTree(bTree->pLchild); if(bTree!=NULL && bTree->pRchild != NULL) preOrder_traverse_binTree(bTree->pRchild); if(bTree!=NULL) visit_node(bTree); return; }
void default_visitor::visit_additive_expression(additive_expression_ast *node) { if (node->expression_sequence) { const list_node<multiplicative_expression_ast*> *__it = node->expression_sequence->to_front(), *__end = __it; do { visit_node(__it->element); __it = __it->next; } while (__it != __end); } }
void default_visitor::visit_program(program_ast *node) { if (node->klass_sequence) { const list_node<class_ast*> *__it = node->klass_sequence->to_front(), *__end = __it; do { visit_node(__it->element); __it = __it->next; } while (__it != __end); } }
void default_visitor::visit_class(class_ast *node) { if (node->feature_sequence) { const list_node<feature_ast*> *__it = node->feature_sequence->to_front(), *__end = __it; do { visit_node(__it->element); __it = __it->next; } while (__it != __end); } }
/** * segregating_sites - calculate the number of segregating sites * * @param n - Node * * @return int - the number of segregating sites */ int segregating_sites(struct Node *n) { int sites = 0; reset_tree(n); while (n != NULL) { if (n != NULL) { if (!n->visited) { n->visited = TRUE; sites += n->mutations; } } n = visit_node(n); } return sites; }
/** * total_branch_length - calculate the total branch length. * * As each node has recorded a coalescent event at the *total* time * point, we need to add the *differences* in time between node and * its parent * * @param n - Node * * @return double - total branch length */ double total_branch_length(struct Node *n) { double tbl = 0.0; reset_tree(n); while (n != NULL) { if (n != NULL) { if (!n->visited && n->parent != NULL) { n->visited = TRUE; tbl += n->parent->time - n->time; } } n = visit_node(n); } return tbl; }
void IdealGraphPrinter::walk_nodes(Node *start, bool edges, VectorSet* temp_set) { VectorSet visited(Thread::current()->resource_area()); GrowableArray<Node *> nodeStack(Thread::current()->resource_area(), 0, 0, NULL); nodeStack.push(start); visited.test_set(start->_idx); if (C->cfg() != NULL) { // once we have a CFG there are some nodes that aren't really // reachable but are in the CFG so add them here. for (uint i = 0; i < C->cfg()->number_of_blocks(); i++) { Block* block = C->cfg()->get_block(i); for (uint s = 0; s < block->number_of_nodes(); s++) { nodeStack.push(block->get_node(s)); } } } while(nodeStack.length() > 0) { Node *n = nodeStack.pop(); visit_node(n, edges, temp_set); if (_traverse_outs) { for (DUIterator i = n->outs(); n->has_out(i); i++) { Node* p = n->out(i); if (!visited.test_set(p->_idx)) { nodeStack.push(p); } } } for ( uint i = 0; i < n->len(); i++ ) { if ( n->in(i) ) { if (!visited.test_set(n->in(i)->_idx)) { nodeStack.push(n->in(i)); } } } } }
// TRAVERSE_FS - Recursively traverses the file system from a given directory int traverse_fs(char *cur_dir, int u_flg, int m_flg, struct stat *stp, char *argv[]){ DIR *dirp; struct dirent *de; char path[MAX_PATH_LEN]; int tmp, retval = 0; // retval is an error count (retval= - # of errors) //Open directory stream if ((dirp = opendir(cur_dir)) == NULL){ fprintf(stderr, "%s: can not open directory %s: %s\n", argv[0], cur_dir, strerror(errno)); errno = 0; // reset for potential later use return -1; } //Read directory entries from stream while ((de = readdir(dirp))!=NULL){ if(strcmp(de->d_name, ".")!=0 && strcmp(de->d_name, "..")!=0){ //Create path to directory entry if (!create_path(cur_dir, path, de->d_name, argv)){ //Visit corresponding node tmp = visit_node(path, u_flg, m_flg, argv, stp); retval+=tmp; //If node is dir and no error, recursively traverse its entries if (de->d_type == DT_DIR && !tmp){ retval+=traverse_fs(path, u_flg, m_flg, stp, argv); } } else{ //error, pathname will overflow buffer retval-=1; } } } if (errno){ // Some error occurred while reading from the directory stream fprintf(stderr, "%s: error occurred while reading directory %s: %s\n", argv[0], cur_dir, strerror(errno)); errno = 0; // reset for potential later use return retval-1; } //Close directory stream closedir(dirp); return retval; }
void default_visitor::visit_primary_expression(primary_expression_ast *node) { visit_node(node->expression); if (node->argument_sequence) { const list_node<expression_ast*> *__it = node->argument_sequence->to_front(), *__end = __it; do { visit_node(__it->element); __it = __it->next; } while (__it != __end); } visit_node(node->if_expression); visit_node(node->while_expression); visit_node(node->block_expression); visit_node(node->let_expression); visit_node(node->case_expression); }
int main(int argc,char *argv[]){ int u_flg = -1; // -1 corresponds to no -u flag supplied int m_flg = 0; // 0 corresponds to no -m flag supplied char *path = NULL; // initial path provided by user struct stat st; int retval = 0; //Parse command line arguments parse_args(argc, argv, &u_flg, &m_flg, &path); //Remove trailing slash in pathname if supplied if (path[strlen(path)-1] == '/') path[strlen(path)-1] = '\0'; //Visit initial node if (visit_node(path, u_flg, m_flg, argv, &st)) return -1; //Recursively visit further nodes if initial node is a directory if (S_ISDIR(st.st_mode)){ return traverse_fs(path, u_flg, m_flg, &st, argv); } return 0; }
void default_visitor::visit_while_expression(while_expression_ast *node) { visit_node(node->condition); visit_node(node->loop_expression); }
void default_visitor::visit_if_expression(if_expression_ast *node) { visit_node(node->condition); visit_node(node->true_expression); visit_node(node->false_expression); }
void default_visitor::visit_expression(expression_ast *node) { visit_node(node->expression); }
void default_visitor::visit_case_condition(case_condition_ast *node) { visit_node(node->expression); }
void Profile::init_configuration(Configuration* config, TiXmlDocument* root) { std::vector<std::string> variable; visit_node(config, root, variable); }
void default_visitor::visit_let_declaration(let_declaration_ast *node) { visit_node(node->expression); }