@Override public void doOperation(int index) throws Exception { int req; if(random.nextFloat() < cachePercent && index > 1) { int maxValid = Math.min(Math.min(Math.max(cache.length, index - 1), uncached.get() - 1), cache.length); int cacheIndex = Math.abs(random.nextInt()) % maxValid; req = cache[cacheIndex]; } else { req = Math.abs(random.nextInt()) % size; cache[uncached.getAndIncrement() % cache.length] = req; } test.doOperation(req); } }
/** * Equivalent to <tt>nextInt()</tt>. This has the effect that random engines * can now be used as function objects, returning a random number upon * function evaluation. */ public int apply(int dummy) { return nextInt(); }
/** Equivalent to <tt>nextInt()</tt>. This has the effect that random engines can now be used as function objects, returning a random number upon function evaluation. */ public int apply(int dummy) { return nextInt(); } /**
/** Equivalent to <tt>nextInt()</tt>. This has the effect that random engines can now be used as function objects, returning a random number upon function evaluation. */ public int apply(int dummy) { return nextInt(); } /**
/** * Returns a 64 bit uniformly distributed random number in the closed interval <tt>[Long.MIN_VALUE,Long.MAX_VALUE]</tt> (including <tt>Long.MIN_VALUE</tt> and <tt>Long.MAX_VALUE</tt>). */ public long nextLong() { // concatenate two 32-bit strings into one 64-bit string return ((nextInt() & 0xFFFFFFFFL) << 32) | ((nextInt() & 0xFFFFFFFFL)); } /**
/** * Returns a 64 bit uniformly distributed random number in the closed * interval <tt>[Long.MIN_VALUE,Long.MAX_VALUE]</tt> (including * <tt>Long.MIN_VALUE</tt> and <tt>Long.MAX_VALUE</tt>). */ public long nextLong() { // concatenate two 32-bit strings into one 64-bit string return ((nextInt() & 0xFFFFFFFFL) << 32) | ((nextInt() & 0xFFFFFFFFL)); }
/** * Returns a 64 bit uniformly distributed random number in the closed interval <tt>[Long.MIN_VALUE,Long.MAX_VALUE]</tt> (including <tt>Long.MIN_VALUE</tt> and <tt>Long.MAX_VALUE</tt>). */ public long nextLong() { // concatenate two 32-bit strings into one 64-bit string return ((nextInt() & 0xFFFFFFFFL) << 32) | ((nextInt() & 0xFFFFFFFFL)); } /**
/** * Returns a 32 bit uniformly distributed random number in the open unit interval <code>(0.0,1.0)</code> (excluding 0.0 and 1.0). */ public double raw() { int nextInt; do { // accept anything but zero nextInt = nextInt(); // in [Integer.MIN_VALUE,Integer.MAX_VALUE]-interval } while (nextInt==0); // transform to (0.0,1.0)-interval // 2.3283064365386963E-10 == 1.0 / Math.pow(2,32) return (double) (nextInt & 0xFFFFFFFFL) * 2.3283064365386963E-10; /* nextInt == Integer.MAX_VALUE --> 0.49999999976716936 nextInt == Integer.MIN_VALUE --> 0.5 nextInt == Integer.MAX_VALUE-1 --> 0.4999999995343387 nextInt == Integer.MIN_VALUE+1 --> 0.5000000002328306 nextInt == 1 --> 2.3283064365386963E-10 nextInt == -1 --> 0.9999999997671694 nextInt == 2 --> 4.6566128730773926E-10 nextInt == -2 --> 0.9999999995343387 */ } }
/** * Returns a 32 bit uniformly distributed random number in the open unit interval <code>(0.0,1.0)</code> (excluding 0.0 and 1.0). */ public double raw() { int nextInt; do { // accept anything but zero nextInt = nextInt(); // in [Integer.MIN_VALUE,Integer.MAX_VALUE]-interval } while (nextInt==0); // transform to (0.0,1.0)-interval // 2.3283064365386963E-10 == 1.0 / Math.pow(2,32) return (double) (nextInt & 0xFFFFFFFFL) * 2.3283064365386963E-10; /* nextInt == Integer.MAX_VALUE --> 0.49999999976716936 nextInt == Integer.MIN_VALUE --> 0.5 nextInt == Integer.MAX_VALUE-1 --> 0.4999999995343387 nextInt == Integer.MIN_VALUE+1 --> 0.5000000002328306 nextInt == 1 --> 2.3283064365386963E-10 nextInt == -1 --> 0.9999999997671694 nextInt == 2 --> 4.6566128730773926E-10 nextInt == -2 --> 0.9999999995343387 */ } }
/** * Returns a 32 bit uniformly distributed random number in the open unit * interval <code>(0.0,1.0)</code> (excluding 0.0 and 1.0). */ public double raw() { int nextInt; do { // accept anything but zero nextInt = nextInt(); // in // [Integer.MIN_VALUE,Integer.MAX_VALUE]-interval } while (nextInt == 0); // transform to (0.0,1.0)-interval // 2.3283064365386963E-10 == 1.0 / Math.pow(2,32) return (double) (nextInt & 0xFFFFFFFFL) * 2.3283064365386963E-10; /* * nextInt == Integer.MAX_VALUE --> 0.49999999976716936 nextInt == * Integer.MIN_VALUE --> 0.5 nextInt == Integer.MAX_VALUE-1 --> * 0.4999999995343387 nextInt == Integer.MIN_VALUE+1 --> * 0.5000000002328306 nextInt == 1 --> 2.3283064365386963E-10 nextInt == * -1 --> 0.9999999997671694 nextInt == 2 --> 4.6566128730773926E-10 * nextInt == -2 --> 0.9999999995343387 */ } }
random = (RandomEngine) randomEngine.clone(); for (int j=0, i=size; --i>=0; j++) { System.out.print(" "+random.nextInt()); if (j%8==7) System.out.println();
random = (RandomEngine) randomEngine.clone(); for (int j=0, i=size; --i>=0; j++) { System.out.print(" "+random.nextInt()); if (j%8==7) System.out.println();