Program: 32813
Project: 32813
Buggy source:
/** 
 * Walks through the union of the specified ranges. All values in the first range are given the specified selection value. All values in the second range but not in the first range are given the opposite selection value. In effect, the first range and the intersection of the two ranges are given the specified value. The parts that are in the second range but not in the first range (ie. everything else) is given the opposite selection value.
 * @param select true to set values in the first range as selected andthe other values in the second range as not selected. false to set values in the first range as not selected and the other values in the second range as selected.
 * @param changeIndex0 one end of the first range, inclusive.
 * @param changeIndex1 the opposite end of the first range, inclusive.This may be lower than changeIndex0.
 * @param invertIndex0 one end of the second range, inclusive. Tospecify an empty second range, specify -1 for this value.
 * @param invertIndex1 the opposite end of the second range, inclusive.This may be lower than invertIndex0. To specify an empty second range, specify -1 for this value.
 */
private void setSubRangeOfRange(boolean select,int changeIndex0,int changeIndex1,int invertIndex0,int invertIndex1){
  if (changeIndex0 >= flagList.size() || changeIndex1 >= flagList.size() || ((changeIndex0 == -1 || changeIndex1 == -1) && changeIndex0 != changeIndex1)) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str" + changeIndex0 + "String_Node_Str"+ changeIndex1+ "String_Node_Str"+ flagList.size());
  }
  if (invertIndex0 >= flagList.size() || invertIndex1 >= flagList.size() || ((invertIndex0 == -1 || invertIndex1 == -1) && invertIndex0 != invertIndex1)) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str" + invertIndex0 + "String_Node_Str"+ invertIndex1+ "String_Node_Str"+ flagList.size());
  }
  if (changeIndex0 == -1 && changeIndex1 == -1) {
    if (invertIndex0 == -1 && invertIndex1 == -1)     return;
    changeIndex0=invertIndex0;
    changeIndex1=invertIndex1;
    select=!select;
  }
  if (invertIndex0 == -1 && invertIndex1 == -1) {
    invertIndex0=changeIndex0;
    invertIndex1=changeIndex1;
  }
  int minChangeIndex=Math.min(changeIndex0,changeIndex1);
  int maxChangeIndex=Math.max(changeIndex0,changeIndex1);
  int minInvertIndex=Math.min(invertIndex0,invertIndex1);
  int maxInvertIndex=Math.max(invertIndex0,invertIndex1);
  int minUnionIndex=Math.min(minChangeIndex,minInvertIndex);
  int maxUnionIndex=Math.max(maxChangeIndex,maxInvertIndex);
  int minChangedIndex=maxUnionIndex + 1;
  int maxChangedIndex=minUnionIndex - 1;
  updates.beginEvent();
  for (int i=minUnionIndex; i <= maxUnionIndex; i++) {
    boolean selectedBefore=(flagList.get(i) != null);
    boolean inChangeRange=(i >= minChangeIndex && i <= maxChangeIndex);
    boolean selectedAfter=(inChangeRange == select);
    if (selectedBefore != selectedAfter) {
      if (i < minChangedIndex)       minChangedIndex=i;
      if (i > maxChangedIndex)       maxChangedIndex=i;
      if (selectedBefore) {
        int selectionIndex=flagList.getCompressedIndex(i);
        flagList.set(i,null);
        updates.addDelete(selectionIndex);
      }
 else {
        flagList.set(i,Boolean.TRUE);
        int selectionIndex=flagList.getCompressedIndex(i);
        updates.addInsert(selectionIndex);
      }
    }
  }
  updates.commitEvent();
  if (minChangedIndex <= maxChangedIndex)   fireSelectionChanged(minChangedIndex,maxChangedIndex);
}

Fixed version (ground truth):
/** 
 * Walks through the union of the specified ranges. All values in the first range are given the specified selection value. All values in the second range but not in the first range are given the opposite selection value. In effect, the first range and the intersection of the two ranges are given the specified value. The parts that are in the second range but not in the first range (ie. everything else) is given the opposite selection value.
 * @param select true to set values in the first range as selected andthe other values in the second range as not selected. false to set values in the first range as not selected and the other values in the second range as selected.
 * @param changeIndex0 one end of the first range, inclusive.
 * @param changeIndex1 the opposite end of the first range, inclusive.This may be lower than changeIndex0.
 * @param invertIndex0 one end of the second range, inclusive. Tospecify an empty second range, specify -1 for this value.
 * @param invertIndex1 the opposite end of the second range, inclusive.This may be lower than invertIndex0. To specify an empty second range, specify -1 for this value.
 */
private void setSubRangeOfRange(boolean select,int changeIndex0,int changeIndex1,int invertIndex0,int invertIndex1){
  if (changeIndex0 >= flagList.size() || changeIndex1 >= flagList.size() || ((changeIndex0 == -1 || changeIndex1 == -1) && changeIndex0 != changeIndex1)) {
    throw new IndexOutOfBoundsException("String_Node_Str" + changeIndex0 + "String_Node_Str"+ changeIndex1+ "String_Node_Str"+ flagList.size());
  }
  if (invertIndex0 >= flagList.size() || invertIndex1 >= flagList.size() || ((invertIndex0 == -1 || invertIndex1 == -1) && invertIndex0 != invertIndex1)) {
    throw new IndexOutOfBoundsException("String_Node_Str" + invertIndex0 + "String_Node_Str"+ invertIndex1+ "String_Node_Str"+ flagList.size());
  }
  if (changeIndex0 == -1 && changeIndex1 == -1) {
    if (invertIndex0 == -1 && invertIndex1 == -1)     return;
    changeIndex0=invertIndex0;
    changeIndex1=invertIndex1;
    select=!select;
  }
  if (invertIndex0 == -1 && invertIndex1 == -1) {
    invertIndex0=changeIndex0;
    invertIndex1=changeIndex1;
  }
  int minChangeIndex=Math.min(changeIndex0,changeIndex1);
  int maxChangeIndex=Math.max(changeIndex0,changeIndex1);
  int minInvertIndex=Math.min(invertIndex0,invertIndex1);
  int maxInvertIndex=Math.max(invertIndex0,invertIndex1);
  int minUnionIndex=Math.min(minChangeIndex,minInvertIndex);
  int maxUnionIndex=Math.max(maxChangeIndex,maxInvertIndex);
  int minChangedIndex=maxUnionIndex + 1;
  int maxChangedIndex=minUnionIndex - 1;
  updates.beginEvent();
  for (int i=minUnionIndex; i <= maxUnionIndex; i++) {
    boolean selectedBefore=(flagList.get(i) != null);
    boolean inChangeRange=(i >= minChangeIndex && i <= maxChangeIndex);
    boolean selectedAfter=(inChangeRange == select);
    if (selectedBefore != selectedAfter) {
      if (i < minChangedIndex)       minChangedIndex=i;
      if (i > maxChangedIndex)       maxChangedIndex=i;
      if (selectedBefore) {
        int selectionIndex=flagList.getCompressedIndex(i);
        flagList.set(i,null);
        updates.addDelete(selectionIndex);
      }
 else {
        flagList.set(i,Boolean.TRUE);
        int selectionIndex=flagList.getCompressedIndex(i);
        updates.addInsert(selectionIndex);
      }
    }
  }
  updates.commitEvent();
  if (minChangedIndex <= maxChangedIndex)   fireSelectionChanged(minChangedIndex,maxChangedIndex);
}