private void resizeArray() {
        HeapNode[] ar2;
        if (heap_size >= ar.length - 4) {
            ar2 = (HeapNode[]) Array.newInstance(HeapNode.class, ar.length * 2);
            System.arraycopy(ar, 0, ar2, 0, ar.length);
            this.ar = ar2;
        }
        if (heap_size < (ar.length / 2) - 1 && ar.length > 100) {
            ar2 = (HeapNode[]) Array.newInstance(HeapNode.class, ar.length / 2);
            System.arraycopy(ar, 0, ar2, 0, ar2.length);
            this.ar = ar2;
        }
    }