@@ -639,268 +639,6 @@ public static <T> T[] sample(T[] source, int k, T[] target) {
639639 return SequenceCompositeSampler .sample (source , k , target , ThreadLocalRandom .current ());
640640 }
641641
642- /**
643- * Generates a random sample of k elements, without replacement, from a given source array. All n
644- * choose k combinations are equally likely, where n is the length of the source array.
645- *
646- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
647- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
648- * 25(1):45-47, 1982.
649- *
650- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
651- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
652- * algorithm uses no extra space.
653- *
654- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
655- * source of randomness.
656- *
657- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
658- * @param source The source array to sample.
659- * @param k The number of random samples (must be no greater than source.length).
660- * @param target An array to hold the result. If target is null or target.length is less than k,
661- * then this method will construct a new array for the result.
662- * @return An array containing the random sample.
663- * @throws IllegalArgumentException if k > source.length
664- * @throws NegativeArraySizeException if k < 0
665- */
666- @ Deprecated
667- public static int [] samplePool (int [] source , int k , int [] target ) {
668- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
669- }
670-
671- /**
672- * Generates a random sample of k elements, without replacement, from a given source array. All n
673- * choose k combinations are equally likely, where n is the length of the source array.
674- *
675- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
676- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
677- * 25(1):45-47, 1982.
678- *
679- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
680- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
681- * algorithm uses no extra space.
682- *
683- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
684- * source of randomness.
685- *
686- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
687- * @param source The source array to sample.
688- * @param k The number of random samples (must be no greater than source.length).
689- * @param target An array to hold the result. If target is null or target.length is less than k,
690- * then this method will construct a new array for the result.
691- * @return An array containing the random sample.
692- * @throws IllegalArgumentException if k > source.length
693- * @throws NegativeArraySizeException if k < 0
694- */
695- @ Deprecated
696- public static long [] samplePool (long [] source , int k , long [] target ) {
697- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
698- }
699-
700- /**
701- * Generates a random sample of k elements, without replacement, from a given source array. All n
702- * choose k combinations are equally likely, where n is the length of the source array.
703- *
704- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
705- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
706- * 25(1):45-47, 1982.
707- *
708- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
709- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
710- * algorithm uses no extra space.
711- *
712- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
713- * source of randomness.
714- *
715- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
716- * @param source The source array to sample.
717- * @param k The number of random samples (must be no greater than source.length).
718- * @param target An array to hold the result. If target is null or target.length is less than k,
719- * then this method will construct a new array for the result.
720- * @return An array containing the random sample.
721- * @throws IllegalArgumentException if k > source.length
722- * @throws NegativeArraySizeException if k < 0
723- */
724- @ Deprecated
725- public static short [] samplePool (short [] source , int k , short [] target ) {
726- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
727- }
728-
729- /**
730- * Generates a random sample of k elements, without replacement, from a given source array. All n
731- * choose k combinations are equally likely, where n is the length of the source array.
732- *
733- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
734- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
735- * 25(1):45-47, 1982.
736- *
737- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
738- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
739- * algorithm uses no extra space.
740- *
741- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
742- * source of randomness.
743- *
744- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
745- * @param source The source array to sample.
746- * @param k The number of random samples (must be no greater than source.length).
747- * @param target An array to hold the result. If target is null or target.length is less than k,
748- * then this method will construct a new array for the result.
749- * @return An array containing the random sample.
750- * @throws IllegalArgumentException if k > source.length
751- * @throws NegativeArraySizeException if k < 0
752- */
753- @ Deprecated
754- public static byte [] samplePool (byte [] source , int k , byte [] target ) {
755- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
756- }
757-
758- /**
759- * Generates a random sample of k elements, without replacement, from a given source array. All n
760- * choose k combinations are equally likely, where n is the length of the source array.
761- *
762- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
763- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
764- * 25(1):45-47, 1982.
765- *
766- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
767- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
768- * algorithm uses no extra space.
769- *
770- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
771- * source of randomness.
772- *
773- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
774- * @param source The source array to sample.
775- * @param k The number of random samples (must be no greater than source.length).
776- * @param target An array to hold the result. If target is null or target.length is less than k,
777- * then this method will construct a new array for the result.
778- * @return An array containing the random sample.
779- * @throws IllegalArgumentException if k > source.length
780- * @throws NegativeArraySizeException if k < 0
781- */
782- @ Deprecated
783- public static char [] samplePool (char [] source , int k , char [] target ) {
784- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
785- }
786-
787- /**
788- * Generates a random sample of k chars, without replacement, from a given source String. All n
789- * choose k combinations are equally likely, where n is the length of the source String.
790- *
791- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
792- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
793- * 25(1):45-47, 1982.
794- *
795- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
796- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
797- * algorithm uses no extra space.
798- *
799- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
800- * source of randomness.
801- *
802- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
803- * @param source The source to sample.
804- * @param k The number of random samples (must be no greater than source.length()).
805- * @param target An array to hold the result. If target is null or target.length is less than k,
806- * then this method will construct a new array for the result.
807- * @return An array containing the random sample.
808- * @throws IllegalArgumentException if k > source.length()
809- * @throws NegativeArraySizeException if k < 0
810- */
811- @ Deprecated
812- public static char [] samplePool (String source , int k , char [] target ) {
813- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
814- }
815-
816- /**
817- * Generates a random sample of k elements, without replacement, from a given source array. All n
818- * choose k combinations are equally likely, where n is the length of the source array.
819- *
820- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
821- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
822- * 25(1):45-47, 1982.
823- *
824- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
825- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
826- * algorithm uses no extra space.
827- *
828- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
829- * source of randomness.
830- *
831- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
832- * @param source The source array to sample.
833- * @param k The number of random samples (must be no greater than source.length).
834- * @param target An array to hold the result. If target is null or target.length is less than k,
835- * then this method will construct a new array for the result.
836- * @return An array containing the random sample.
837- * @throws IllegalArgumentException if k > source.length
838- * @throws NegativeArraySizeException if k < 0
839- */
840- @ Deprecated
841- public static double [] samplePool (double [] source , int k , double [] target ) {
842- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
843- }
844-
845- /**
846- * Generates a random sample of k elements, without replacement, from a given source array. All n
847- * choose k combinations are equally likely, where n is the length of the source array.
848- *
849- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
850- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
851- * 25(1):45-47, 1982.
852- *
853- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
854- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
855- * algorithm uses no extra space.
856- *
857- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
858- * source of randomness.
859- *
860- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
861- * @param source The source array to sample.
862- * @param k The number of random samples (must be no greater than source.length).
863- * @param target An array to hold the result. If target is null or target.length is less than k,
864- * then this method will construct a new array for the result.
865- * @return An array containing the random sample.
866- * @throws IllegalArgumentException if k > source.length
867- * @throws NegativeArraySizeException if k < 0
868- */
869- @ Deprecated
870- public static float [] samplePool (float [] source , int k , float [] target ) {
871- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
872- }
873-
874- /**
875- * Generates a random sample of k elements, without replacement, from a given source array. All n
876- * choose k combinations are equally likely, where n is the length of the source array.
877- *
878- * <p>This implements the algorithm SELECT of S. Goodman and S. Hedetniemi, as described in: J
879- * Ernvall, O Nevalainen, "An Algorithm for Unbiased Random Sampling," The Computer Journal,
880- * 25(1):45-47, 1982.
881- *
882- * <p>The runtime is O(n) and it generates O(k) random numbers. Thus, it is a better choice than
883- * sampleReservoir when k < n-k. However, this uses O(n) extra space, whereas the reservoir
884- * algorithm uses no extra space.
885- *
886- * <p>This method is safe to use with threads, as it uses ThreadLocalRandom as the underlying
887- * source of randomness.
888- *
889- * @deprecated This method is deprecated, and replaced by the {@link SequencePoolSampler} class.
890- * @param source The source array to sample.
891- * @param k The number of random samples (must be no greater than source.length).
892- * @param target An array to hold the result. If target is null or target.length is less than k,
893- * then this method will construct a new array for the result.
894- * @param <T> The type of array elements.
895- * @return An array containing the random sample.
896- * @throws IllegalArgumentException if k > source.length
897- * @throws NegativeArraySizeException if k < 0
898- */
899- @ Deprecated
900- public static <T > T [] samplePool (T [] source , int k , T [] target ) {
901- return SequencePoolSampler .sample (source , k , target , ThreadLocalRandom .current ());
902- }
903-
904642 /**
905643 * Generates a random sample of k elements, without replacement, from a given source array. All n
906644 * choose k combinations are equally likely, where n is the length of the source array.
0 commit comments