/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link java.util.BitSet} instead, and * using {@link java.util.BitSet#nextSetBit(int)} or {@link java.util.BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link java.util.BitSet} instead, and * using {@link java.util.BitSet#nextSetBit(int)} or {@link java.util.BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link java.util.BitSet} instead, and * using {@link java.util.BitSet#nextSetBit(int)} or {@link java.util.BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
public void testIndexOf_arrays() { assertEquals(-1, Booleans.indexOf(EMPTY, false)); assertEquals(-1, Booleans.indexOf(ARRAY_FALSE, true)); assertEquals(-1, Booleans.indexOf(ARRAY_FALSE_FALSE, true)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE, false)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE_TRUE, false)); assertEquals(1, Booleans.indexOf(ARRAY_FALSE_TRUE, true)); assertEquals(2, Booleans.indexOf(new boolean[] {false, false, true}, true)); }
public void testIndexOf() { assertEquals(-1, Booleans.indexOf(EMPTY, ARRAY_FALSE)); assertEquals(-1, Booleans.indexOf(ARRAY_FALSE, ARRAY_FALSE_TRUE)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE_FALSE, ARRAY_FALSE)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE, ARRAY_FALSE)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE_TRUE, ARRAY_FALSE)); assertEquals(1, Booleans.indexOf(ARRAY_FALSE_TRUE, ARRAY_TRUE)); assertEquals(0, Booleans.indexOf(ARRAY_TRUE, new boolean[0])); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link java.util.BitSet} instead, and * using {@link java.util.BitSet#nextSetBit(int)} or {@link java.util.BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link java.util.BitSet} instead, and * using {@link java.util.BitSet#nextSetBit(int)} or {@link java.util.BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link * java.util.BitSet} instead, and using {@link * java.util.BitSet#nextSetBit(int)} or {@link * java.util.BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean target) { return indexOf(array, target, 0, array.length); }
/** * Returns the index of the first appearance of the value {@code target} in * {@code array}. * * <p><b>Note:</b> consider representing the array as a {@link BitSet} * instead, and using {@link BitSet#nextSetBit(int)} or {@link * BitSet#nextClearBit(int)}. * * @param array an array of {@code boolean} values, possibly empty * @param target a primitive {@code boolean} 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(boolean[] array, boolean 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 Boolean) { return Booleans.indexOf(array, ((Boolean) o).booleanValue()); } return -1; }
public void testIndexOf() { assertEquals(-1, Booleans.indexOf(EMPTY, ARRAY_FALSE)); assertEquals(-1, Booleans.indexOf(ARRAY_FALSE, ARRAY_FALSE_TRUE)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE_FALSE, ARRAY_FALSE)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE, ARRAY_FALSE)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE_TRUE, ARRAY_FALSE)); assertEquals(1, Booleans.indexOf(ARRAY_FALSE_TRUE, ARRAY_TRUE)); assertEquals(0, Booleans.indexOf(ARRAY_TRUE, new boolean[0])); }
public void testIndexOf_arrays() { assertEquals(-1, Booleans.indexOf(EMPTY, false)); assertEquals(-1, Booleans.indexOf(ARRAY_FALSE, true)); assertEquals(-1, Booleans.indexOf(ARRAY_FALSE_FALSE, true)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE, false)); assertEquals(0, Booleans.indexOf(ARRAY_FALSE_TRUE, false)); assertEquals(1, Booleans.indexOf(ARRAY_FALSE_TRUE, true)); assertEquals(2, Booleans.indexOf(new boolean[] {false, false, true}, true)); }