public static boolean isContiguous ( int [ ] indices , int diff ) { if ( indices . length < 1 ) return true ; for ( int i = 1 ; i < indices . length ; i ++ ) { if ( Math . abs ( indices [ i ] - indices [ i - 1 ] ) > diff ) return false ; } return true ; }
Returns whether indices are contiguous by a certain amount or not