bool sorttest(int array[], int n, int threshold) { Comparable* A[n]; Comparable* temp[n]; int i; /* Sort an array of Ints */ for (i = 0; i < n; ++i) { A[i] = new Int(array[i]); } for (int i = 0; i < n; ++i) { temp[i] = new Int(0); } // for (i = 0; i < n; ++i) { // cout << *A[i] << " "; // } // cout << std::endl; mergesortOpt(A, temp, 0, n-1); if (!checkorder(A, n)) return false; for (i = 0; i < n; ++i) { delete A[i]; } for (int i = 0; i < n; ++i) { delete temp[i]; } /* Sort an array of KVPairs */ for (i = 0; i < n; ++i) { A[i] = new KVPair(array[i], &array[i]); } for (int i = 0; i < n; ++i) { temp[i] = new KVPair(0, 0); } mergesortOpt(A, temp, 0, n-1); if (!checkorder(A, n)) return false; for (i = 0; i < n; ++i) { delete A[i]; } for (int i = 0; i < n; ++i) { delete temp[i]; } delete[] array; return true; }
static void order_a(t_push **lista, t_push **listb, t_action **actions) { while (!checkorder(*lista)) { if (get_last(*lista) > get_before_last(*lista)) swap_a(lista, listb, actions); else push_b(lista, listb, actions); order_b(lista, listb, actions); } }
static void order_b(t_push **lista, t_push **listb, t_action **actions) { while (checklen(*listb) > 1 && !checkorder(*listb)) { if (get_last(*listb) < get_before_last(*listb)) { swap_b(lista, listb, actions); push_a(lista, listb, actions); } else break ; } }