static boolean isSorted ( Iterable < ? extends TimeSeriesCollection > tscIterable ) { final Iterator < ? extends TimeSeriesCollection > iter = tscIterable . iterator ( ) ; if ( ! iter . hasNext ( ) ) return true ; // Empty collection is ordered. DateTime timestamp = iter . next ( ) . getTimestamp ( ) ; while ( iter . hasNext ( ) ) { final DateTime nextTimestamp = iter . next ( ) . getTimestamp ( ) ; if ( ! nextTimestamp . isAfter ( timestamp ) ) return false ; timestamp = nextTimestamp ; } return true ; }
Validation function to check if an iterable is sorted with ascending timestamps .