001package algs14;
002import java.util.function.Function;
003import stdlib.*;
004
005public class DoublingImproved {
006
007        private static final int MAXVAL = 10000;
008        public static void main(String[] args) {
009                Function<Integer, int[]> generator = N -> ArrayGenerator.intRandom (N, -MAXVAL, MAXVAL);
010                StdOut.println ("One");
011                DoublingTest.run (200000, 8, 2, generator, (int[] x) -> XOneSum.count (x));
012
013                StdOut.println ("Two");
014                DoublingTest.run (200, 8, 2, generator, (int[] x) -> XTwoSum.count (x));
015
016                StdOut.println ("Three");
017                DoublingTest.run (200, 5, 2, generator, (int[] x) -> ThreeSum.count(x));
018
019                StdOut.println ("Four");
020                DoublingTest.run (200, 3, 2, generator, (int[] x) -> XFourSum.count(x));
021
022                StdOut.println ("Two Fast");
023                DoublingTest.run (200, 8, 2, generator, (int[] x) -> XTwoSumFast.count (x));
024
025                StdOut.println ("Three Fast");
026                DoublingTest.run (200, 5, 2, generator, (int[] x) -> ThreeSumFast.count (x));
027        }
028}