protected String checkHeap(){
  if (comparator == null) {
    for (int i=1; i < size; i++) {
      final int parent=(i - 1) >>> 1;
      @SuppressWarnings("unchecked") Comparable<Object> po=(Comparable<Object>)queue[parent];
      if (po.compareTo(queue[i]) > 0) {
        return "@" + parent + ": "+ queue[parent]+ " < @"+ i+ ": "+ queue[i];
      }
    }
  }
 else {
    for (int i=1; i < size; i++) {
      final int parent=(i - 1) >>> 1;
      if (comparator.compare(queue[parent],queue[i]) > 0) {
        return "@" + parent + ": "+ queue[parent]+ " < @"+ i+ ": "+ queue[i];
      }
    }
  }
  return null;
}

protected String checkHeap ( ) { if ( comparator == null ) { for ( int i = 1 ; i < size ; i ++ ) { final int parent = ( i - 1 ) > > > 1 ; @ SuppressWarnings ( "unchecked" ) Comparable < Object > po = ( Comparable < Object > ) queue [ parent ] ; if ( po . compareTo ( queue [ i ] ) > 0 ) { return "@" + parent + ": " + queue [ parent ] + " < @" + i + ": " + queue [ i ] ; } } } else { for ( int i = 1 ; i < size ; i ++ ) { final int parent = ( i - 1 ) > > > 1 ; if ( comparator . compare ( queue [ parent ] , queue [ i ] ) > 0 ) { return "@" + parent + ": " + queue [ parent ] + " < @" + i + ": " + queue [ i ] ; } } } return null ; }
test whether the heap is still valid . debug method .
