#include "common.h"
#include "heap.h"

#define EPSILON 1e-10

static int heap_compare_int(HEAP *h, int i1, int i2)
{
    /* TODO */
}

static int heap_compare_double(HEAP *h, int i1, int i2)
{
    /* TODO */
}

static int heap_compare_str(HEAP *h, int i1, int i2)
{
    /* TODO */
}


int main(int ac, char *av[])
{
    int i, n, *int_array;
    double f, *d_array;
    HEAP h1, h2;  /* test both (init_heap + insert) and build_heap */

    if (ac < 2)
        ERR_MESG("Usage: gheap-testing <type> [element1 element2 ... ]");
    switch(av[1][0]) {
    case 'i': /* integer */
        if (init_heap(&h1, ????) ||
            NULL == (int_array = Malloc(ac-2, int)))
            ERR_MESG("heap-testing: out of memory");

        for (i = 2; i < ac; i++) {
            n = atoi(av[i]);
            insert(&h1, ...);
            int_array[i-2] = n;
        }
        if (build_heap(&h2, ...))
            return -1;

        printf("Successive delete_min/maxs from h1:\n");
        for (i = 0; i < ac-2; i++) {
            /* call delete_max */
            printf("%d ", ????);
        }
        putchar('\n');

        heapsort(&h2);
        printf("Result of heapsorting h2:\n");
        for (i = 0; i < ac-2; i++) /* TODO */
        putchar('\n');
        break;

    case 'f': /*double */
        if (init_heap(&h1, ...) ||
            NULL == (d_array = Malloc(ac-2, double)))
            ERR_MESG("heap-testing: out of memory");

        for (i = 2; i < ac; i++) {
            f = atof(av[i]);
            insert(&h1, ...);
            d_array[i-2] = f;
        }
        if (build_heap(&h2, ...))
            return -1;

        printf("Successive delete_min/maxs from h1:\n");
        for (i = 0; i < ac-2; i++) {
            /* call delete_max */
            printf("%.4f ", ????);
        }
        putchar('\n');

        heapsort(&h2);
        printf("Result of heapsorting h2:\n");
        for (i = 0; i < ac-2; i++)
            printf("%.4f ", ???);
        putchar('\n');
        break;

    default:
        fprintf(stderr, "Unknown type %s\n", av[1]);
        break;
    }

    free_heap(&h1); free_heap(&h2);
    return 0;
}
