private static int maxFinishIndexedBinarySearch(
            List<? extends TemporalProposition> list, long tstamp) {
        int low = 0;
        int high = list.size() - 1;

        while (low <= high) {
            /*
             * We use >>> instead of >> or /2 to avoid overflow. Sun's
             * implementation of binary search actually doesn't do this (bug
             * #5045582).
             */
            int mid = (low + high) >>> 1;
            TemporalProposition midVal = list.get(mid);
            Long maxFinish = midVal.getInterval().getMaximumFinish();
            int cmp = maxFinish != null ? maxFinish.compareTo(tstamp) : 1;
            if (cmp < 0) {
                low = mid + 1;
            } else if (cmp > 0) {
                high = mid - 1;
            } else {
                return mid + 1;
            }
        }

        return high + 1;
    }
private static int maxFinishIndexedBinarySearch ( List < ? extends TemporalProposition > list , long tstamp ) { int low = 0 ; int high = list . size ( ) - 1 ; while ( low <= high ) { int mid = ( low + high ) > > > 1 ; TemporalProposition midVal = list . get ( mid ) ; Long maxFinish = midVal . getInterval ( ) . getMaximumFinish ( ) ; int cmp = maxFinish != null ? maxFinish . compareTo ( tstamp ) : 1 ; if ( cmp < 0 ) { low = mid + 1 ; } else if ( cmp > 0 ) { high = mid - 1 ; } else { return mid + 1 ; } } return high + 1 ; }
Binary search for a primitive parameter by timestamp, optimized for when
the parameters are stored in a list that implements
<code>java.util.RandomAccess</code>.

@param list
a <code>List</code> of <code>PrimitiveParameter</code>
objects all with the same paramId, cannot be <code>null</code>.
@param tstamp
the timestamp we're interested in finding.
@return a <code>PrimitiveParameter</code>, or <code>null</code> if
not found.