3939import org .apache .commons .lang3 .builder .ToStringStyle ;
4040import org .apache .commons .lang3 .math .NumberUtils ;
4141import org .apache .commons .lang3 .mutable .MutableInt ;
42+ import org .apache .commons .lang3 .stream .IntStreams ;
4243import org .apache .commons .lang3 .stream .Streams ;
4344
4445/**
@@ -1572,6 +1573,10 @@ public static boolean contains(final boolean[] array, final boolean valueToFind)
15721573 * <p>
15731574 * The method returns {@code false} if a {@code null} array is passed in.
15741575 * </p>
1576+ * <p>
1577+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1578+ * {@link Arrays#sort(byte[])} and {@link Arrays#binarySearch(byte[], byte)}.
1579+ * </p>
15751580 *
15761581 * @param array the array to search through
15771582 * @param valueToFind the value to find
@@ -1586,6 +1591,10 @@ public static boolean contains(final byte[] array, final byte valueToFind) {
15861591 * <p>
15871592 * The method returns {@code false} if a {@code null} array is passed in.
15881593 * </p>
1594+ * <p>
1595+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1596+ * {@link Arrays#sort(char[])} and {@link Arrays#binarySearch(char[], char)}.
1597+ * </p>
15891598 *
15901599 * @param array the array to search through
15911600 * @param valueToFind the value to find
@@ -1601,6 +1610,10 @@ public static boolean contains(final char[] array, final char valueToFind) {
16011610 * <p>
16021611 * The method returns {@code false} if a {@code null} array is passed in.
16031612 * </p>
1613+ * <p>
1614+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1615+ * {@link Arrays#sort(double[])} and {@link Arrays#binarySearch(double[], double)}.
1616+ * </p>
16041617 *
16051618 * @param array the array to search through
16061619 * @param valueToFind the value to find
@@ -1618,6 +1631,10 @@ public static boolean contains(final double[] array, final double valueToFind) {
16181631 * The method returns {@code false} if a {@code null} array
16191632 * is passed in.
16201633 * </p>
1634+ * <p>
1635+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1636+ * {@link Arrays#sort(double[])} and {@link Arrays#binarySearch(double[], double)}.
1637+ * </p>
16211638 *
16221639 * @param array the array to search
16231640 * @param valueToFind the value to find
@@ -1633,6 +1650,10 @@ public static boolean contains(final double[] array, final double valueToFind, f
16331650 * <p>
16341651 * The method returns {@code false} if a {@code null} array is passed in.
16351652 * </p>
1653+ * <p>
1654+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1655+ * {@link Arrays#sort(float[])} and {@link Arrays#binarySearch(float[], float)}.
1656+ * </p>
16361657 *
16371658 * @param array the array to search through
16381659 * @param valueToFind the value to find
@@ -1647,6 +1668,10 @@ public static boolean contains(final float[] array, final float valueToFind) {
16471668 * <p>
16481669 * The method returns {@code false} if a {@code null} array is passed in.
16491670 * </p>
1671+ * <p>
1672+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1673+ * {@link Arrays#sort(int[])} and {@link Arrays#binarySearch(int[], int)}.
1674+ * </p>
16501675 *
16511676 * @param array the array to search through
16521677 * @param valueToFind the value to find
@@ -1661,6 +1686,10 @@ public static boolean contains(final int[] array, final int valueToFind) {
16611686 * <p>
16621687 * The method returns {@code false} if a {@code null} array is passed in.
16631688 * </p>
1689+ * <p>
1690+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1691+ * {@link Arrays#sort(long[])} and {@link Arrays#binarySearch(long[], long)}.
1692+ * </p>
16641693 *
16651694 * @param array the array to search through
16661695 * @param valueToFind the value to find
@@ -1675,6 +1704,10 @@ public static boolean contains(final long[] array, final long valueToFind) {
16751704 * <p>
16761705 * The method returns {@code false} if a {@code null} array is passed in.
16771706 * </p>
1707+ * <p>
1708+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1709+ * {@link Arrays#sort(Object[], Comparator)} and {@link Arrays#binarySearch(Object[], Object)}.
1710+ * </p>
16781711 *
16791712 * @param array the array to search through
16801713 * @param objectToFind the object to find
@@ -1689,6 +1722,10 @@ public static boolean contains(final Object[] array, final Object objectToFind)
16891722 * <p>
16901723 * The method returns {@code false} if a {@code null} array is passed in.
16911724 * </p>
1725+ * <p>
1726+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1727+ * {@link Arrays#sort(short[])} and {@link Arrays#binarySearch(short[], short)}.
1728+ * </p>
16921729 *
16931730 * @param array the array to search through
16941731 * @param valueToFind the value to find
@@ -1698,14 +1735,37 @@ public static boolean contains(final short[] array, final short valueToFind) {
16981735 return indexOf (array , valueToFind ) != INDEX_NOT_FOUND ;
16991736 }
17001737
1738+ /**
1739+ * Checks if any of the ints are in the given array.
1740+ * <p>
1741+ * The method returns {@code false} if a {@code null} array is passed in.
1742+ * </p>
1743+ * <p>
1744+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1745+ * {@link Arrays#sort(int[])} and {@link Arrays#binarySearch(int[], int)}.
1746+ * </p>
1747+ *
1748+ * @param array the array to search through
1749+ * @param objectsToFind any of the ints to find
1750+ * @return {@code true} if the array contains any of the ints
1751+ * @since 3.18.0
1752+ */
1753+ public static boolean containsAny (final int [] array , final int ... objectsToFind ) {
1754+ return IntStreams .of (objectsToFind ).anyMatch (e -> contains (array , e ));
1755+ }
1756+
17011757 /**
17021758 * Checks if any of the objects are in the given array.
17031759 * <p>
17041760 * The method returns {@code false} if a {@code null} array is passed in.
17051761 * </p>
1762+ * <p>
1763+ * If the {@code array} elements you are searching implement {@link Comparator}, consider whether it is worth using
1764+ * {@link Arrays#sort(Object[], Comparator)} and {@link Arrays#binarySearch(Object[], Object)}.
1765+ * </p>
17061766 *
1707- * @param array the array to search through
1708- * @param objectsToFind any of the objects to find
1767+ * @param array the array to search through
1768+ * @param objectsToFind any of the objects to find
17091769 * @return {@code true} if the array contains any of the objects
17101770 * @since 3.13.0
17111771 */
0 commit comments