Beispiel #1
0
void *
__push_jmp_point()
{
	unsigned long thread_id = cur_thread;
	spinLock(&spin_lk);
	rbInsert(&stack_tree, &thread_id);
	spinUnlock(&spin_lk);
	struct RBNode *stack = rbSearch(stack_tree, &thread_id);
	struct stack_node *new_node = malloc(sizeof(struct stack_node));
	assert(new_node != NULL);
	new_node->prev = to_stack(stack)->stack_top;
	to_stack(stack)->stack_top = new_node;
	return new_node->jb;
}
Beispiel #2
0
int main(int argc, char **argv){
	RBTree T = NULL;
	Node   *x;
	int i = 0;
	for (i = 1; i <= 20; i++)
		rbInsert(&T, i);
	// rbInsert(&T,80);
	// rbInsert(&T,90);
	// rbInsert(&T,40);
	// rbDelete(&T,rbSearch(T,130));
	// rbDelete(&T,rbSearch(T,90));
	rbPrint(T);
	printf("max=%d\n", rbMaxKey(T)->key);
	printf("min=%d\n", rbMinKey(T)->key);
	printf("search=%d\n", rbSearch(T, 16)->key);
	return 0;
}
Beispiel #3
0
int main()
{
    struct Tree *T = malloc(sizeof(struct Tree));
    T->nil = malloc(sizeof(struct node));
    T->nil->col = BLACK;
    T->nil->p = NULL;
    T->root = T->nil;
    int n = 1;
    while (n != 0) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            rbInsert(T, n);
        }
    }
    rbPrint(T, T->root);
    printf("\n");
    return 0;
}