1 package it.unimi.dsi.fastutil; 2 3 23 24 25 29 30 public class Arrays { 31 32 private Arrays() {} 33 34 44 public static void ensureFromTo( final int arrayLength, final int from, final int to ) { 45 if ( from < 0 ) throw new ArrayIndexOutOfBoundsException ( "Start index (" + from + ") is negative" ); 46 if ( from > to ) throw new IllegalArgumentException ( "Start index (" + from + ") is greater than end index (" + to + ")" ); 47 if ( to > arrayLength ) throw new ArrayIndexOutOfBoundsException ( "End index (" + to + ") is greater than array length (" + arrayLength + ")" ); 48 } 49 50 60 public static void ensureOffsetLength( final int arrayLength, final int offset, final int length ) { 61 if ( offset < 0 ) throw new ArrayIndexOutOfBoundsException ( "Offset (" + offset + ") is negative" ); 62 if ( length < 0 ) throw new IllegalArgumentException ( "Length (" + length + ") is negative" ); 63 if ( offset + length > arrayLength ) throw new ArrayIndexOutOfBoundsException ( "Last index (" + ( offset + length ) + ") is greater than array length (" + arrayLength + ")" ); 64 } 65 66 } 67 | Popular Tags |