int n_rounds (struct world *world, int delta) { int i; int display_incrementally; int ret, ret2; if (abs (delta) < 10) { display_incrementally = 1; } else { display_incrementally = 0; } if (delta<0) { for (i=0;i>delta;i--) { if ((ret=round_backward (world, display_incrementally)) != 0) break; } } else { for (i=0;i<delta;i++) { if ((ret=round_forward (world, display_incrementally)) != 0) break; } } if (!display_incrementally) { if ((ret2=update_everything (world))!=0) return ret2; } return ret; }
int main(void){ printf("Pruebas > Listas recorribles\n"); //Prueba de lista circular t_round* round = round_create(); alloc(elem, int); *elem = 1; round_add(round, elem); alloc(elem); *elem = 2; round_add(round, elem); alloc(elem); *elem = 3; round_add(round, elem); while(!round_has_ended(round)){ elem = round_get(round); printf("%d\n", *elem); round_forward(round); } round_restart(round); while(!round_has_ended(round)){ elem = round_remove(round); dealloc(elem); } round_dispose(round); //Prueba del macro foreach t_list* lista = list_create(); char* a = "elemento 1!"; char* b = "elemento 2!"; char* c = "elemento 3!"; list_add(lista, a); list_add(lista, b); list_add(lista, c); foreach(item, lista, char*){ printf("%s\n", item); }