////////////////////////////////////////////////////////////Funcoes Tree
void elemento_central(tree **root,char formula[],int l,int r){


   int i, cont = 0;

    if(l>=r){
        if(formula[l]=='x'||formula[l]=='y'||formula[l]=='z'){
            /*root =*/ add_root(root,formula[l]); // ADICIONAR O ELEMENTO NA ROOT// EXPRESSAO BEM FEITA
            return; // BEM_FORMULADA
        }

        return; // MAL FORMULADA
    }
    if(formula[l]!='('){
        if(formula[l]=='x'||formula[l]=='y'||formula[l]=='z'){
           /*root =*/add_root(root,formula[l]); // ADICIONAR O ELEMENTO NA ROOT// EXPRESSAO BEM FEITA

            return; // BEM_FORMULADA
        }

        return; // MAL FORMULADA
    }
    if(formula[r]!=')'){
        if(formula[r]=='x'||formula[r]=='y'||formula[r]=='z'){
           /*root =*/ add_root(root,formula[r]); // ADICIONAR O ELEMENTO NA ROOT// EXPRESSAO BEM FEITA

            return; // BEM_FORMULADA
        }

        return; // MAL FORMULADA
    }

    for(i=l;i<=r;i++){
        if(formula[i]=='(')cont++;
        if(formula[i]==')')cont--;
        if(cont==1&&(formula[i]=='-'||formula[i]=='^')){
                /*root =*/ add_root(root,formula[i]);//ADICIONAR O ELEMENTO CENTRAL NA ROOT
                elemento_central(&root[0]->left,formula,l,i-1);// ADICIONAR O ELEMENTO CENTRAL DO SUBCONJUNTO DA ESQUERDA NA ROOT->LEFT
                elemento_central(&root[0]->right,formula,i+1,r);// ADICIONAR O ELEMMENTO CENTRAL DO SUBCONJUNTO DA DIREITA NA ROOT->RIGHT
               break;
        }



    }

}
Пример #2
0
litehtml::element* litehtml::document::add_body() {
     if (!m_root) {
	  add_root();
     }
     element* el = new el_body(this);
     el->set_tagName(L"body");
     m_root->appendChild(el);
     return el;
}
Пример #3
0
static int __list_subvol_search(int fd, struct root_lookup *root_lookup)
{
	int ret;
	struct btrfs_ioctl_search_args args;
	struct btrfs_ioctl_search_key *sk = &args.key;
	struct btrfs_ioctl_search_header *sh;
	struct btrfs_root_ref *ref;
	unsigned long off = 0;
	int name_len;
	char *name;
	u64 dir_id;
	int i;

	root_lookup_init(root_lookup);
	memset(&args, 0, sizeof(args));

	root_lookup_init(root_lookup);

	memset(&args, 0, sizeof(args));

	/* search in the tree of tree roots */
	sk->tree_id = 1;

	/*
	 * set the min and max to backref keys.  The search will
	 * only send back this type of key now.
	 */
	sk->max_type = BTRFS_ROOT_BACKREF_KEY;
	sk->min_type = BTRFS_ROOT_BACKREF_KEY;

	/*
	 * set all the other params to the max, we'll take any objectid
	 * and any trans
	 */
	sk->max_objectid = (u64)-1;
	sk->max_offset = (u64)-1;
	sk->max_transid = (u64)-1;

	/* just a big number, doesn't matter much */
	sk->nr_items = 4096;

	while(1) {
		ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
		if (ret < 0)
			return ret;
		/* the ioctl returns the number of item it found in nr_items */
		if (sk->nr_items == 0)
			break;

		off = 0;

		/*
		 * for each item, pull the key out of the header and then
		 * read the root_ref item it contains
		 */
		for (i = 0; i < sk->nr_items; i++) {
			sh = (struct btrfs_ioctl_search_header *)(args.buf +
								  off);
			off += sizeof(*sh);
			if (sh->type == BTRFS_ROOT_BACKREF_KEY) {
				ref = (struct btrfs_root_ref *)(args.buf + off);
				name_len = btrfs_stack_root_ref_name_len(ref);
				name = (char *)(ref + 1);
				dir_id = btrfs_stack_root_ref_dirid(ref);

				add_root(root_lookup, sh->objectid, sh->offset,
					 dir_id, name, name_len);
			}

			off += sh->len;

			/*
			 * record the mins in sk so we can make sure the
			 * next search doesn't repeat this root
			 */
			sk->min_objectid = sh->objectid;
			sk->min_type = sh->type;
			sk->min_offset = sh->offset;
		}
		sk->nr_items = 4096;
		/* this iteration is done, step forward one root for the next
		 * ioctl
		 */
		if (sk->min_type < BTRFS_ROOT_BACKREF_KEY) {
			sk->min_type = BTRFS_ROOT_BACKREF_KEY;
			sk->min_offset = 0;
		} else  if (sk->min_objectid < (u64)-1) {
			sk->min_objectid++;
			sk->min_type = BTRFS_ROOT_BACKREF_KEY;
			sk->min_offset = 0;
		} else
			break;
	}

	return 0;
}
Пример #4
0
void Tree<T> :: math_parse(char* exp)
{
    add_root('0', &Tree_Node);
    math_parse(exp,&Tree_Node);
}