/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
public void testIndexOf() { assertEquals(-1, Shorts.indexOf(EMPTY, (short) 1)); assertEquals(-1, Shorts.indexOf(ARRAY1, (short) 2)); assertEquals(-1, Shorts.indexOf(ARRAY234, (short) 1)); assertEquals(0, Shorts.indexOf(new short[] {(short) -1}, (short) -1)); assertEquals(0, Shorts.indexOf(ARRAY234, (short) 2)); assertEquals(1, Shorts.indexOf(ARRAY234, (short) 3)); assertEquals(2, Shorts.indexOf(ARRAY234, (short) 4)); assertEquals( 1, Shorts.indexOf(new short[] {(short) 2, (short) 3, (short) 2, (short) 3}, (short) 3)); }
public void testIndexOf_arrayTarget() { assertEquals(0, Shorts.indexOf(EMPTY, EMPTY)); assertEquals(0, Shorts.indexOf(ARRAY234, EMPTY)); assertEquals(-1, Shorts.indexOf(EMPTY, ARRAY234)); assertEquals(-1, Shorts.indexOf(ARRAY234, ARRAY1)); assertEquals(-1, Shorts.indexOf(ARRAY1, ARRAY234)); assertEquals(0, Shorts.indexOf(ARRAY1, ARRAY1)); assertEquals(0, Shorts.indexOf(ARRAY234, ARRAY234)); assertEquals(0, Shorts.indexOf(ARRAY234, new short[] {(short) 2, (short) 3})); assertEquals(1, Shorts.indexOf(ARRAY234, new short[] {(short) 3, (short) 4})); assertEquals(1, Shorts.indexOf(ARRAY234, new short[] {(short) 3})); assertEquals(2, Shorts.indexOf(ARRAY234, new short[] {(short) 4})); assertEquals( 1, Shorts.indexOf( new short[] {(short) 2, (short) 3, (short) 3, (short) 3, (short) 3}, new short[] {(short) 3})); assertEquals( 2, Shorts.indexOf( new short[] { (short) 2, (short) 3, (short) 2, (short) 3, (short) 4, (short) 2, (short) 3 assertEquals( 1, Shorts.indexOf( new short[] { (short) 2, (short) 2, (short) 3, (short) 4, (short) 2, (short) 3, (short) 4 assertEquals(
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or * {@code -1} if no such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * @param array an array of {@code short} values, possibly empty * @param target a primitive {@code short} value * @return the least index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int indexOf(short[] array, short target) { return indexOf(array, target, 0, array.length); }
/** * {@inheritDoc} * * @throws NullPointerException * if the wrapped array was <code>null</code>. */ @Override public int indexOf(Object o) { // Will make the method fail if array is null. if (size() < 1) { return -1; } if (o instanceof Short) { return Shorts.indexOf(array, ((Short) o).shortValue()); } return -1; }
public void testIndexOf() { assertEquals(-1, Shorts.indexOf(EMPTY, (short) 1)); assertEquals(-1, Shorts.indexOf(ARRAY1, (short) 2)); assertEquals(-1, Shorts.indexOf(ARRAY234, (short) 1)); assertEquals(0, Shorts.indexOf( new short[] {(short) -1}, (short) -1)); assertEquals(0, Shorts.indexOf(ARRAY234, (short) 2)); assertEquals(1, Shorts.indexOf(ARRAY234, (short) 3)); assertEquals(2, Shorts.indexOf(ARRAY234, (short) 4)); assertEquals(1, Shorts.indexOf( new short[] { (short) 2, (short) 3, (short) 2, (short) 3 }, (short) 3)); }