protected void heapifyIterative(int i)
        {
            int parentIndex = parent(i);

            boolean swap = true;

            while(parentIndex >= 0 && swap) {
                swap = false;
                if (this.heapType==HeapType.MAX_HEAP && this.array[parentIndex].compareTo(this.array[i]) < 0)
                    swap = true;
                else if (this.heapType==HeapType.MIN_HEAP && this.array[parentIndex].compareTo(this.array[i]) > 0)
                    swap = true;

                if (swap) {
                    swap(parentIndex, i);
                    i = parentIndex;
                    parentIndex = parent(parentIndex);
                }
            }
        }