1 16 package org.apache.commons.math.random; 17 18 import java.util.Random ; 19 20 27 public class RandomAdaptor extends Random implements RandomGenerator { 28 29 30 private RandomGenerator randomGenerator = null; 31 32 35 private RandomAdaptor() { } 36 37 42 public RandomAdaptor(RandomGenerator randomGenerator) { 43 this.randomGenerator = randomGenerator; 44 } 45 46 53 public static Random createAdaptor(RandomGenerator randomGenerator) { 54 return new RandomAdaptor(randomGenerator); 55 } 56 57 60 public boolean nextBoolean() { 61 return randomGenerator.nextBoolean(); 62 } 63 64 67 public void nextBytes(byte[] bytes) { 68 randomGenerator.nextBytes(bytes); 69 } 70 71 74 public double nextDouble() { 75 return randomGenerator.nextDouble(); 76 } 77 78 81 public float nextFloat() { 82 return randomGenerator.nextFloat(); 83 } 84 85 88 public double nextGaussian() { 89 return randomGenerator.nextGaussian(); 90 } 91 92 95 public int nextInt() { 96 return randomGenerator.nextInt(); 97 } 98 99 102 public int nextInt(int n) { 103 return randomGenerator.nextInt(n); 104 } 105 106 109 public long nextLong() { 110 return randomGenerator.nextLong(); 111 } 112 113 116 public void setSeed(long seed) { 117 if (randomGenerator != null) { randomGenerator.setSeed(seed); 119 } 120 } 121 } 122 | Popular Tags |