private void fixupSuccessor(int lastIndex, int insertIndex, int runIndex, int runCount, int ebc, int successorEbc) {
        if (insertIndex > runIndex) {
            putRunCount(runIndex, insertIndex - runIndex);
        }
        //
        // Test whether fixup is in the middle or at the end of a run
        //
        if (runIndex + runCount > insertIndex) {
            //
            // The fixup happens in the middle of the run, so this is easy. The
            // successor will now run of length 1.
            //
            putRunCount(insertIndex, -1);
            putRunCount(insertIndex + 1, 0);
            int remainingRunCount = runCount - (insertIndex - runIndex) - 1;
            if (insertIndex + 2 < lastIndex) {
                if (remainingRunCount > 0) {
                    putRunCount(insertIndex + 2, remainingRunCount);
                }
            }
        } else {
            //
            // The kb that's been fixed up is the final member of a run.
            // (Otherwise we should not be here.
            //
            Debug.$assert0.t(runIndex + runCount == insertIndex);
            //
            // The fixup is on the last element of the run.
            //
            putRunCount(insertIndex, runCount - 1);

            int successorRunCount = insertIndex + 1 < lastIndex ? getRunCount(insertIndex + 1) : 0;
            Debug.$assert0.t(successorRunCount <= 0);
            putRunCount(insertIndex, successorRunCount - 1);

            if (insertIndex + 2 < lastIndex) {
                int secondSuccessorEbc = getEbc(insertIndex + 2);
                if (successorEbc == secondSuccessorEbc) {
                    //
                    // The fixup has made the successor kb the new start of a
                    // run.
                    //
                    int secondSuccessorRunCount = getRunCount(insertIndex + 2);
                    if (secondSuccessorRunCount >= 0) {
                        putRunCount(insertIndex + 1, secondSuccessorRunCount + 1);
                        putRunCount(insertIndex + 2, 0);
                    } else {
                        putRunCount(insertIndex + 1, 1);
                    }
                } else {
                    int newCrossCount = successorEbc < secondSuccessorEbc ? computeCrossCount(successorEbc,
                            insertIndex + 1, lastIndex, insertIndex) : 0;
                    putRunCount(insertIndex + 1, newCrossCount);
                }
            } else {
                Debug.$assert0.t(insertIndex + 1 < lastIndex);
                putRunCount(insertIndex + 1, 0);
            }
        }
    }