/* Set the prioryty of a cell TODO move the cell of queue if needed */ void board_set_priority(Board *board, Cell *cell, int priority) { if (cell->priority != priority) { cell->priority = priority; if (priority == 1) { stack_push(board->stack_a, stack_remove(board->stack_b, cell)); } else { stack_push(board->stack_b, stack_remove(board->stack_a, cell)); } } }
void event_destroynotify( xcb_generic_event_t* e ) { printf( "yawn: destroynotify\n" ); xcb_destroy_notify_event_t* ev = (xcb_destroy_notify_event_t*)e; stack_remove( ev->window ); stack_tile(); window_current_update(); }
stack_for_each(data_cache_storage, data_entry_variant) { data_entry_t* entry = variant_get_ptr(data_entry_variant); if(memcmp(entry->key, key, sizeof(data_entry_key_t)) == 0) { stack_remove(data_cache_storage, data_entry_variant); variant_free(data_entry_variant); return; } }
int main(int argc, char **argv) { stack_t on_stack; int i; stack_init(&on_stack, argc); for (i = 0; i < argc; i++) stack_push(&on_stack, strdup(argv[i]), -1, NULL); for (i = 0; i < argc; i++) { printf("on_stack.ptr[%d]: %s\n",i, (char *)on_stack.ptr[i]); stack_remove(&on_stack, on_stack.ptr[i], stack_compare_string, NULL, true); } stack_free(&on_stack, NULL); return 0; }
static void run_stack_test(void) { struct stack on_stack; int i; stack_init(&on_stack, 5); for (i = 0; i < 10; i++) { char *p; if (asprintf(&p, "stack %d", i) < 0) return; stack_push(&on_stack, p, -1, NULL); } for (i = 0; i < 10; i++) { printf("on_stack.ptr[%d]: %s\n",i, (char *)on_stack.ptr[i]); stack_remove(&on_stack, on_stack.ptr[i], stack_compare_string, NULL, false); } stack_free(&on_stack, NULL); }
int main(void) { int d1 = 10; int d2 = 20; int d3 = 30; stack_t stack; stack_init(&stack, pcb_cmp_priority, pcb_has_pid); printf("push: \"%d\"\n",d1); stack_push(&stack, &d1); print_list(&stack); printf("push: \"%d\"\n",d2); stack_push(&stack, &d2); print_list(&stack); printf("push: \"%d\"\n",d3); stack_push(&stack, &d3); print_list(&stack); printf("pop: \"%d\"\n", *(int *)stack_pop(&stack)); print_list(&stack); printf("pop: \"%d\"\n", *(int *)stack_pop(&stack)); print_list(&stack); printf("push: \"%d\"\n",d3); stack_push(&stack, &d3); print_list(&stack); printf("pop: \"%d\"\n", *(int *)stack_pop(&stack)); print_list(&stack); printf("pop: \"%d\"\n", *(int *)stack_pop(&stack)); print_list(&stack); printf("push: \"%d\"\n",d1); stack_push(&stack, &d1); print_list(&stack); printf("push: \"%d\"\n",d2); stack_push(&stack, &d2); print_list(&stack); printf("push: \"%d\"\n",d3); stack_push(&stack, &d3); print_list(&stack); printf("peek: \"%d\"\n", *(int *)stack_peek(&stack)); print_list(&stack); printf("remove 20:\n"); stack_remove(&stack, &d2); print_list(&stack); printf("pop:\n"); stack_pop(&stack); print_list(&stack); printf("pop:\n"); stack_pop(&stack); print_list(&stack); return 0; }