Ejemplo n.º 1
0
int query_up(int u, int v) {
    int uchain, vchain = chainInd[v], ans = -1;
 
    while(1) {
        if(uchain == vchain) {
            int cur = query_tree(1, 0, ptr, posInBase[v]+1, posInBase[u]+1);
            if( cur > ans ) ans = cur;
            break;
        }
        int cur = query_tree(1, 0, ptr, posInBase[chainHead[uchain]], posInBase[u]+1);
        if( cur > ans ) ans = cur;
        u = chainHead[uchain];
        u = parent(u);
    }
    return ans;
}
	T query_tree (int tree_index,int curr_L,int curr_R,int L,int R,Func f)
	{
		/*
		* Out Of Range Condition
		*/

		if ((curr_L > curr_R) || (curr_L > R) || (curr_R < L))
			return -1;

		if ((curr_L >= L) && (curr_R <= R))
		{
			return tree[tree_index];
		}

		T query_left = query_tree (tree_index*2,curr_L,(curr_L+curr_R)/2,L,R,f);

		T query_right = query_tree((tree_index*2)+1,((curr_L+curr_R)/2)+1,curr_R,L,R,f);

		T result = f(query_left,query_right);

		return result;

	}
Ejemplo n.º 3
0
void query_desktops(monitor_t *m, domain_t dom, coordinates_t loc, unsigned int depth, FILE *rsp)
{
	for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
		if (loc.desktop != NULL && d != loc.desktop)
			continue;
		for (unsigned int i = 0; i < depth; i++)
			fprintf(rsp, "\t");
		if (dom == DOMAIN_DESKTOP) {
			fprintf(rsp, "%s\n", d->name);
			continue;
		} else {
			fprintf(rsp, "%s %u %i %i,%i,%i,%i %c %c%s\n", d->name, d->border_width,
			        d->window_gap,
			        d->top_padding, d->right_padding, d->bottom_padding, d->left_padding,
			        (d->layout == LAYOUT_TILED ? 'T' : 'M'), (d->floating ? 'f' : '-'),
			        (d == m->desk ? " *" : ""));
		}
		query_tree(d, d->root, rsp, depth + 1);
	}
}
	T query_tree (int L,int R,Func f)
	{
		return query_tree(1,0,size-1,L,R,f);
	}