private void heapify(int startIndex) {
        int left, right, max;
        int size = queueSize;
        while (true) {
            left = startIndex << 1;
            right = left + 1;
            if ((left <= size) && (isMoreOptimalPriority(queuePriority.get(startIndex), queuePriority.get(left)))) {
                max = left;
            } else {
                max = startIndex;
            }
            if ((right <= size) && (isMoreOptimalPriority(queuePriority.get(max), queuePriority.get(right)))) {
                max = right;
            }
            if (max != startIndex) {
                swap(max, startIndex);
                startIndex = max;
            } else {
                break;
            }
        }
    }