### Question:
Utils { public static boolean anyIdCollides( long[] first, int firstLength, long[] other, int otherLength ) { int f = 0; int o = 0; while ( f < firstLength && o < otherLength ) { if ( first[f] == other[o] ) { return true; } if ( first[f] < other[o] ) { while ( ++f < firstLength && first[f] < other[o] ) { } } else { while ( ++o < otherLength && first[f] > other[o] ) { } } } return false; } private  Utils(); static boolean unsignedCompare( long dataA, long dataB, CompareType compareType ); static CompareType unsignedDifference( long dataA, long dataB ); static boolean anyIdCollides( long[] first, int firstLength, long[] other, int otherLength ); static void mergeSortedInto( long[] values, long[] into, int intoLengthBefore );  }### Answer:
@Test public void shouldDetectCollisions() { long[] first = new long[] {1, 4, 7, 10, 100, 101}; long[] other = new long[] {2, 3, 34, 75, 101}; boolean collides = Utils.anyIdCollides( first, first.length, other, other.length ); assertTrue( collides ); }
@Test public void shouldNotReportDisjointArraysAsCollision() { long[] first = new long[] {1, 4, 7, 10, 100, 101}; long[] other = new long[] {2, 3, 34, 75, 102}; boolean collides = Utils.anyIdCollides( first, first.length, other, other.length ); assertFalse( collides ); }
@Test public void shouldBeCorrectForSomeRandomBatches() { Random random = ThreadLocalRandom.current(); long[][] batches = new long[20][]; for ( int i = 0; i < batches.length; i++ ) { batches[i] = randomBatch( 1_000, random, 5_000_000 ); } for ( long[] rBatch : batches ) { for ( long[] lBatch : batches ) { assertEquals( actuallyCollides( rBatch, lBatch ), Utils.anyIdCollides( rBatch, rBatch.length, lBatch, lBatch.length ) ); } } }