Exemplo n.º 1
0
int is_bst2(tree *T) // level traverse
{
    tree *t = NULL;
    qinit();
    my_enqueue(T);
    while (qcount > 0) {
        t = my_dequeue();
        if (t) {
            if ((t->left && t->value < t->left->value) || (t->right && t->value > t->right->value)) {
                return 0;
            }
            if (t->left) my_enqueue(t->left);
            if (t->right) my_enqueue(t->right);
        }
    }
    return 1;
}
Exemplo n.º 2
0
/*
 * This file implements a reorder scheduler for a single queue.
 * The queue is allocated as part of the scheduler instance,
 * and there is a single flowset is in the template which stores
 * queue size and policy.
 * Enqueue and dequeue use the default library functions.
 */
static int 
reorder_enqueue(struct dn_sch_inst *si, struct dn_queue *q, struct mbuf *m)
{
	/* XXX if called with q != NULL and m=NULL, this is a
	 * re-enqueue from an existing scheduler, which we should
	 * handle.
	 */
	struct my_queue* my_q = (struct my_queue *)(si+1);
	printf("reorder: reorder_enqueue\n");
	return my_enqueue(my_q, m) ? 0 : 1;
}