public String report(){
  StringBuffer report=new StringBuffer();
  intHashTable=new int[table.tableSize];
  calculateSlotUsage();
  int max=maxCollisions();
  int[] slotUsageCount=new int[max + 1];
  for (  int i : intHashTable) {
    slotUsageCount[i]++;
  }
  report.append("Total number of entries: " + numEntries + "\n");
  report.append("   Load factor:" + (numEntries / (1.0f * table.tableSize) + "\n\n"));
  float weightedAvg=0.0f;
  int numNonEmpty=0;
  report.append("Number of hits\tNumber of slots\n");
  for (int j=0; j <= max; j++) {
    if (slotUsageCount[j] != 0) {
      report.append(j + "\t" + slotUsageCount[j]+ "\n");
      if (j != 0) {
        weightedAvg+=slotUsageCount[j] * j;
        numNonEmpty+=slotUsageCount[j];
      }
    }
  }
  weightedAvg/=numNonEmpty;
  report.append("\n  Slot statistics: min=" + minCollisions() + ", max="+ max+ ", weightedAvg:"+ weightedAvg);
  return report.toString();
}

public String report ( ) { StringBuffer report = new StringBuffer ( ) ; intHashTable = new int [ table . tableSize ] ; calculateSlotUsage ( ) ; int max = maxCollisions ( ) ; int [ ] slotUsageCount = new int [ max + 1 ] ; for ( int i : intHashTable ) { slotUsageCount [ i ] ++ ; } report . append ( "Total number of entries: " + numEntries + "\n" ) ; report . append ( "   Load factor:" + ( numEntries / ( 1.0f * table . tableSize ) + "\n\n" ) ) ; float weightedAvg = 0.0f ; int numNonEmpty = 0 ; report . append ( "Number of hits\tNumber of slots\n" ) ; for ( int j = 0 ; j <= max ; j ++ ) { if ( slotUsageCount [ j ] != 0 ) { report . append ( j + "\t" + slotUsageCount [ j ] + "\n" ) ; if ( j != 0 ) { weightedAvg += slotUsageCount [ j ] * j ; numNonEmpty += slotUsageCount [ j ] ; } } } weightedAvg /= numNonEmpty ; report . append ( "\n  Slot statistics: min=" + minCollisions ( ) + ", max=" + max + ", weightedAvg:" + weightedAvg ) ; return report . toString ( ) ; }
generate and return the collision report .
