/** * Menu function that handles the event when someone clicks "Animate sorting" * or "Exit." In the case of the former, we will set up the subwindows. * * @param value - the menu item clicked. */ void mymenu(int value) { if (value == 1) { mergesort_counter = 0; quicksort_counter = 0; xs_mergesort = generate_random_list(); xs_quicksort = malloc(xs_size * sizeof(int)); cp_array(xs_mergesort, xs_quicksort, xs_size); // push onto the mergesort stack mergesort_stack = make_stack(); int *initial_array = malloc(xs_size * sizeof(int)); cp_array(xs_mergesort, initial_array, xs_size); Node *initial_node = make_node(initial_array, xs_size, unsorted); initial_node->start_index = 0; initial_node->end_index = xs_size - 1; push(mergesort_stack, initial_node); // push onto the quicksort stack quicksort_stack = make_stack(); Sublist *initial_list = make_sublist(0, xs_size - 1); push(quicksort_stack, initial_list); recreate_subwindows(); glutIdleFunc(update_lists); in_intro = false; } if (value == 2) exit(0); }
void push_data(D stack, D data){ int cnt = stack->intv++; for(; cnt>0; cnt--) stack = stack->next; data = make_copy(data); if(data->next != NULL) data = make_sublist(data); stack->next = data; }
static int cl_list_dereference (SLtype type, VOID_STAR addr) { SLang_List_Type *list; (void) type; list = *(SLang_List_Type **) addr; if (NULL == (list = make_sublist (list, 0, list->length))) return -1; return push_list (list, 1); /* will delete upon failure */ }
static void list_concat (SLang_List_Type *l1, SLang_List_Type *l2) { SLang_List_Type *list; if (NULL == (list = make_sublist (l1, 0, l1->length))) return; if (-1 == list_join_internal (list, l2)) { free_list (list); return; } (void) push_list (list, 1); /* will delete upon failure */ }