public @NonNegative int index(@Time @NonNegative final double t){
  final @NonNegative int i=closestIndex(t);
  if (Closeness.isCloseEnough(t,times.get(i)))   return i;
 else   if (t < front())   throw new IllegalArgumentException("using inadequate time grid: all nodes are later than the required time t = " + t + " (earliest node is t1 = "+ times.first()+ ")");
 else   if (t > back())   throw new IllegalArgumentException("using inadequate time grid: all nodes are earlier than the required time t = " + t + " (latest node is t1 = "+ back()+ ")");
 else {
    int j, k;
    if (t > times.get(i)) {
      j=i;
      k=i + 1;
    }
 else {
      j=i - 1;
      k=i;
    }
    throw new IllegalArgumentException("using inadequate time grid: the nodes closest to the required time t = " + t + " are t1 = "+ times.get(j)+ " and t2 = "+ times.get(k));
  }
}

public @ NonNegative int index ( @ Time @ NonNegative final double t ) { final @ NonNegative int i = closestIndex ( t ) ; if ( Closeness . isCloseEnough ( t , times . get ( i ) ) ) return i ; else if ( t < front ( ) ) throw new IllegalArgumentException ( "using inadequate time grid: all nodes are later than the required time t = " + t + " (earliest node is t1 = " + times . first ( ) + ")" ) ; else if ( t > back ( ) ) throw new IllegalArgumentException ( "using inadequate time grid: all nodes are earlier than the required time t = " + t + " (latest node is t1 = " + back ( ) + ")" ) ; else { int j , k ; if ( t > times . get ( i ) ) { j = i ; k = i + 1 ; } else { j = i - 1 ; k = i ; } throw new IllegalArgumentException ( "using inadequate time grid: the nodes closest to the required time t = " + t + " are t1 = " + times . get ( j ) + " and t2 = " + times . get ( k ) ) ; } }
time grid with mandatory time points < p > mandatory points are guaranteed to belong to the grid . additional points are then added with regular spacing between pairs of mandatory times in order to reach the desired number of steps .
