You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/main/java/org/apache/commons/lang3/ArrayUtils.java
+132-45
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@
20
20
importjava.lang.reflect.Field;
21
21
importjava.lang.reflect.Method;
22
22
importjava.lang.reflect.Type;
23
+
importjava.security.SecureRandom;
23
24
importjava.util.Arrays;
24
25
importjava.util.BitSet;
25
26
importjava.util.Comparator;
@@ -4721,6 +4722,11 @@ public static <T> T[] nullToEmpty(final T[] array, final Class<T[]> type) {
4721
4722
returnarray;
4722
4723
}
4723
4724
4725
+
/**
4726
+
* Gets the {@link ThreadLocalRandom} for {@code shuffle} methods that don't take a {@link Random} argument.
4727
+
*
4728
+
* @return the current ThreadLocalRandom.
4729
+
*/
4724
4730
privatestaticThreadLocalRandomrandom() {
4725
4731
returnThreadLocalRandom.current();
4726
4732
}
@@ -7640,9 +7646,17 @@ public static void shift(final short[] array, int startIndexInclusive, int endIn
7640
7646
}
7641
7647
7642
7648
/**
7643
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7649
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7650
+
* algorithm</a>.
7651
+
* <p>
7652
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7653
+
* </p>
7654
+
* <p>
7655
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7668
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7669
+
* algorithm</a>.
7655
7670
*
7656
-
* @param array the array to shuffle
7657
-
* @param random the source of randomness used to permute the elements
7671
+
* @param array the array to shuffle
7672
+
* @param random the source of randomness used to permute the elements
@@ -7665,9 +7680,17 @@ public static void shuffle(final boolean[] array, final Random random) {
7665
7680
}
7666
7681
7667
7682
/**
7668
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7683
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7684
+
* algorithm</a>.
7685
+
* <p>
7686
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7687
+
* </p>
7688
+
* <p>
7689
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7702
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7703
+
* algorithm</a>.
7680
7704
*
7681
-
* @param array the array to shuffle
7682
-
* @param random the source of randomness used to permute the elements
7705
+
* @param array the array to shuffle
7706
+
* @param random the source of randomness used to permute the elements
@@ -7690,9 +7714,17 @@ public static void shuffle(final byte[] array, final Random random) {
7690
7714
}
7691
7715
7692
7716
/**
7693
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7717
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7718
+
* algorithm</a>.
7719
+
* <p>
7720
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7721
+
* </p>
7722
+
* <p>
7723
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7736
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7737
+
* algorithm</a>.
7705
7738
*
7706
-
* @param array the array to shuffle
7707
-
* @param random the source of randomness used to permute the elements
7739
+
* @param array the array to shuffle
7740
+
* @param random the source of randomness used to permute the elements
@@ -7715,9 +7748,17 @@ public static void shuffle(final char[] array, final Random random) {
7715
7748
}
7716
7749
7717
7750
/**
7718
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7751
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7752
+
* algorithm</a>.
7753
+
* <p>
7754
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7755
+
* </p>
7756
+
* <p>
7757
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7770
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7771
+
* algorithm</a>.
7730
7772
*
7731
-
* @param array the array to shuffle
7732
-
* @param random the source of randomness used to permute the elements
7773
+
* @param array the array to shuffle
7774
+
* @param random the source of randomness used to permute the elements
@@ -7740,9 +7782,17 @@ public static void shuffle(final double[] array, final Random random) {
7740
7782
}
7741
7783
7742
7784
/**
7743
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7785
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7786
+
* algorithm</a>.
7787
+
* <p>
7788
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7789
+
* </p>
7790
+
* <p>
7791
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7804
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7805
+
* algorithm</a>.
7755
7806
*
7756
-
* @param array the array to shuffle
7757
-
* @param random the source of randomness used to permute the elements
7807
+
* @param array the array to shuffle
7808
+
* @param random the source of randomness used to permute the elements
@@ -7765,9 +7816,17 @@ public static void shuffle(final float[] array, final Random random) {
7765
7816
}
7766
7817
7767
7818
/**
7768
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7819
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7820
+
* algorithm</a>.
7821
+
* <p>
7822
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7823
+
* </p>
7824
+
* <p>
7825
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7838
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7839
+
* algorithm</a>.
7780
7840
*
7781
-
* @param array the array to shuffle
7782
-
* @param random the source of randomness used to permute the elements
7841
+
* @param array the array to shuffle
7842
+
* @param random the source of randomness used to permute the elements
@@ -7790,9 +7850,17 @@ public static void shuffle(final int[] array, final Random random) {
7790
7850
}
7791
7851
7792
7852
/**
7793
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7853
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7854
+
* algorithm</a>.
7855
+
* <p>
7856
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7857
+
* </p>
7858
+
* <p>
7859
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7872
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7873
+
* algorithm</a>.
7805
7874
*
7806
-
* @param array the array to shuffle
7807
-
* @param random the source of randomness used to permute the elements
7875
+
* @param array the array to shuffle
7876
+
* @param random the source of randomness used to permute the elements
@@ -7815,9 +7884,17 @@ public static void shuffle(final long[] array, final Random random) {
7815
7884
}
7816
7885
7817
7886
/**
7818
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7887
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7888
+
* algorithm</a>.
7889
+
* <p>
7890
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7891
+
* </p>
7892
+
* <p>
7893
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7906
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7907
+
* algorithm</a>.
7830
7908
*
7831
-
* @param array the array to shuffle
7832
-
* @param random the source of randomness used to permute the elements
7909
+
* @param array the array to shuffle
7910
+
* @param random the source of randomness used to permute the elements
@@ -7840,9 +7918,17 @@ public static void shuffle(final Object[] array, final Random random) {
7840
7918
}
7841
7919
7842
7920
/**
7843
-
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7921
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7922
+
* algorithm</a>.
7923
+
* <p>
7924
+
* This method uses the current {@link ThreadLocalRandom} as its random number generator.
7925
+
* </p>
7926
+
* <p>
7927
+
* Instances of {@link ThreadLocalRandom} are not cryptographically secure. For security-sensitive applications, consider using a {@code shuffle} method
* Randomly permutes the elements of the specified array using the Fisher-Yates algorithm.
7940
+
* Shuffles randomly the elements of the specified array using the <a href="https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle
7941
+
* algorithm</a>.
7855
7942
*
7856
-
* @param array the array to shuffle
7857
-
* @param random the source of randomness used to permute the elements
7943
+
* @param array the array to shuffle
7944
+
* @param random the source of randomness used to permute the elements
0 commit comments