Esempio n. 1
0
node *leaves(node *root)
{
	node *temp=root;
	if(temp==NULL)
		return NULL;
	if(temp->left==NULL&&temp->right==NULL)
		printf("%d\n",temp->data);
	leaves(temp->left);
	leaves(temp->right);

}
Esempio n. 2
0
void Node::leaves(Node* node, std::vector<Node*>& leafVector)
{
	if(node->isLeaf())
		leafVector.push_back(node);

	for(unsigned int i = 0; i < node->numberOfChildren(); i++)
		leaves(node->child(i), leafVector);
}
Esempio n. 3
0
int leaves (mpc_ast_t *t) {

    if (strstr(t->tag, "number"))   { return 1; }
    if (strstr(t->tag, "operator")) { return 1; }
    else {
        int total = 0;
        for (int i = 0; i < t->children_num; i++) {
            total = total + leaves(t->children[i]);
        }
        return total;
    }
    return 0;
}
Esempio n. 4
0
core::RigidBody setup_as_rigid_body(Hierarchy h) {
  IMP_USAGE_CHECK(h.get_is_valid(true),
                     "Invalid hierarchy passed to setup_as_rigid_body");
  IMP_WARN("create_rigid_body should be used instead of setup_as_rigid_body"
           << " as the former allows one to get volumes correct at coarser"
           << " levels of detail.");
  core::XYZs leaves(get_leaves(h));
  core::RigidBody rbd
    = core::RigidBody::setup_particle(h, leaves);
  rbd.set_coordinates_are_optimized(true);
  ParticlesTemp internal= core::get_internal(h);
  for (unsigned int i=0; i< internal.size(); ++i) {
    if (internal[i] != h) {
      core::RigidMembers leaves(get_leaves(Hierarchy(internal[i])));
      if (!leaves.empty()) {
        algebra::ReferenceFrame3D rf
            = core::get_initial_reference_frame(get_as<ParticlesTemp>(leaves));
        core::RigidBody::setup_particle(internal[i], rf);
      }
    }
  }
  IMP_INTERNAL_CHECK(h.get_is_valid(true), "Invalid hierarchy produced");
  return rbd;
}
Esempio n. 5
0
int main(int argc, char** argv){
    
    mpc_parser_t* Number    = mpc_new("number"); 
    mpc_parser_t* Operator  = mpc_new("operator"); 
    mpc_parser_t* Expr      = mpc_new("expr"); 
    mpc_parser_t* Lispy     = mpc_new("lispy"); 

   mpca_lang(MPCA_LANG_DEFAULT,
           "                                                                \
                number      :   /-?[0-9]+/                            ;     \
                operator    :   '+' | '-' | '*' | '/' |  '%'          ;     \
                expr        :   <number> | '(' <operator> <expr>+ ')' ;     \
                lispy       :   /^/ <operator> <expr>+ /$/            ;     \
           ",
           Number, Operator, Expr, Lispy);
    
    puts("Leaver Version 0.0.0.0.3\n");
    puts("Press Ctrl+c to Exit\n");
    //puts("..or just kill yourself.. \n");
    
    while (1) {
    
        char *input = readline("leaver$ ");
        add_history(input);

        mpc_result_t r;
        if (mpc_parse("<stdin>", input, Lispy, &r)) {
        
            int result = leaves(r.output);
            printf("%i\n", result);
            mpc_ast_delete(r.output);
        
        } else {
            mpc_err_print(r.error);
            mpc_err_delete(r.error);
        }
        
        free(input);
    }

    mpc_cleanup(4, Number, Operator, Expr, Lispy);

    return 0;
}
Esempio n. 6
0
int _tmain(int argc, _TCHAR* argv[])
{
	root=insert(1);
	root->left=insert(2);
	root->right=insert(3);
	root->left->left=insert(4);
	root->left->right=insert(5);
	root->right->left=insert(7);
	root->right->right=insert(9);
	root->left->left->right=insert(6);
	root->right->left->right=insert(8);
	printf("the binary tree is\n");
	inorder(root);
	printf("the boudary nodes are\n");
	leftboundarynotleaf(root);
	leaves(root);
	rightboundarynotleaf(root);
	while(top>=0)
		printf("%d\n",pop());
	printf("the reverse inorer is\n");
	reverse(root);
	return 0;
}
Esempio n. 7
0
BinaryTree leaves(BinaryTree t) {
  if(t->l == NULL && t->r == NULL) return 1;
	else return leaves(t->l) + leaves(t->r);
}
Esempio n. 8
0
std::vector<Node*> Node::leaves()
{
	std::vector<Node*> leafVector;
	leaves(this, leafVector);
	return leafVector;
}