Program: 58352
Project: 58352
Buggy source:
/** 
 * Sorts the content of the virtual arrays of this heat map wrapper according to the occurences in the foreign VAs. The parameter specifies whether elements should be hidden or not. If all elements occur in the foreign VA the parameter has no effect but increased performance
 * @param foreignContentVAs
 * @param hideVisible
 */
private void sort(ArrayList<ContentVirtualArray> foreignContentVAs,boolean hideVisible,boolean considerSelectedGroups){
  ContentGroupList groupList=contentVA.getGroupList();
  for (int groupIndex=groupList.size() - 1; groupIndex >= 0; groupIndex--) {
    Group group=groupList.get(groupIndex);
    if (!considerSelectedGroups || selectedGroups.containsKey(group)) {
      GLHeatMap heatMap=hashHeatMaps.get(group.getGroupIndex());
      int nrGenes=group.getContainedNrGenes();
      ContentVirtualArray contentVA=heatMap.getContentVA();
      if (useSorting) {
        for (        ContentVirtualArray foreignVA : foreignContentVAs) {
          Integer foreignContentLastOrdererIndex=0;
          for (int contentIndex=0; contentIndex < nrGenes; contentIndex++) {
            Integer contentID=contentVA.get(contentIndex);
            int foreignIndex=foreignVA.indexOf(contentID);
            if (foreignIndex != -1) {
              foreignVA.move(foreignIndex,foreignContentLastOrdererIndex++);
            }
          }
        }
        if (hideVisible) {
          SelectionDelta contentSelectionDelta=new SelectionDelta(EIDType.EXPRESSION_INDEX);
          for (int contentIndex=nrGenes; contentIndex < contentVA.size(); contentIndex++) {
            SelectionDeltaItem item=new SelectionDeltaItem();
            item.setPrimaryID(contentVA.get(contentIndex));
            item.setSelectionType(GLHeatMap.SELECTION_HIDDEN);
            contentSelectionDelta.add(item);
          }
          SelectionUpdateEvent event=new SelectionUpdateEvent();
          event.setSender(this);
          event.setSelectionDelta(contentSelectionDelta);
          eventPublisher.triggerEvent(event);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Sorts the content of the virtual arrays of this heat map wrapper according to the occurences in the foreign VAs. The parameter specifies whether elements should be hidden or not. If all elements occur in the foreign VA the parameter has no effect but increased performance
 * @param foreignContentVAs
 * @param hideVisible
 */
public void sort(ArrayList<ContentVirtualArray> foreignContentVAs,boolean hideVisible,boolean considerSelectedGroups){
  ContentGroupList groupList=contentVA.getGroupList();
  for (int groupIndex=groupList.size() - 1; groupIndex >= 0; groupIndex--) {
    Group group=groupList.get(groupIndex);
    if (!considerSelectedGroups || selectedGroups.containsKey(group)) {
      GLHeatMap heatMap=hashHeatMaps.get(group.getGroupIndex());
      int nrGenes=group.getContainedNrGenes();
      ContentVirtualArray contentVA=heatMap.getContentVA();
      if (useSorting) {
        for (        ContentVirtualArray foreignVA : foreignContentVAs) {
          Integer foreignContentLastOrdererIndex=0;
          for (int contentIndex=0; contentIndex < nrGenes; contentIndex++) {
            Integer contentID=contentVA.get(contentIndex);
            int foreignIndex=foreignVA.indexOf(contentID);
            if (foreignIndex != -1) {
              foreignVA.move(foreignIndex,foreignContentLastOrdererIndex++);
            }
          }
        }
        if (hideVisible) {
          SelectionDelta contentSelectionDelta=new SelectionDelta(EIDType.EXPRESSION_INDEX);
          for (int contentIndex=nrGenes; contentIndex < contentVA.size(); contentIndex++) {
            SelectionDeltaItem item=new SelectionDeltaItem();
            item.setPrimaryID(contentVA.get(contentIndex));
            item.setSelectionType(GLHeatMap.SELECTION_HIDDEN);
            contentSelectionDelta.add(item);
          }
          SelectionUpdateEvent event=new SelectionUpdateEvent();
          event.setSender(this);
          event.setSelectionDelta(contentSelectionDelta);
          eventPublisher.triggerEvent(event);
        }
      }
    }
  }
}