private void assertSortedByDistance ( DoubleDBIDList results ) { // TODO: sort results instead? double dist = - 1.0 ; boolean sorted = true ; for ( DoubleDBIDListIter it = results . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { double qr = it . doubleValue ( ) ; if ( qr < dist ) { sorted = false ; } dist = qr ; } if ( ! sorted ) { try { ModifiableDoubleDBIDList . class . cast ( results ) . sort ( ) ; } catch ( ClassCastException | UnsupportedOperationException e ) { LoggingUtil . warning ( "WARNING: results not sorted by distance!" , e ) ; } } }
Ensure that the results are sorted by distance .