KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > impl > HotBitsRandomGenerator


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.impl;
11
12 import org.jgap.*;
13 import org.jgap.util.*;
14
15 /**
16  * Random generator using the HotBits random generators (they are pluggable
17  * here) and adapts the interface to org.jgap.RandomGenerator
18  *
19  * @author Klaus Meffert
20  * @since 2.3
21  */

22 public class HotBitsRandomGenerator
23     implements RandomGenerator {
24   /** String containing the CVS revision. Read out via reflection!*/
25   private final static String JavaDoc CVS_REVISION = "$Revision: 1.2 $";
26
27   private randomX m_randomGenerator;
28
29   public HotBitsRandomGenerator(randomX a_randomGenerator) {
30     m_randomGenerator = a_randomGenerator;
31   }
32
33   public randomX getRandomGenerator() {
34     return m_randomGenerator;
35   }
36
37   public byte nextByte() {
38     return m_randomGenerator.nextByte();
39   }
40
41   public int nextInt() {
42     return m_randomGenerator.nextInt();
43   }
44
45   public int nextInt(int ceiling) {
46     return m_randomGenerator.nextInt() % ceiling;
47   }
48
49   public long nextLong() {
50     return m_randomGenerator.nextLong();
51   }
52
53   public double nextDouble() {
54     return m_randomGenerator.nextDouble();
55   }
56
57   public float nextFloat() {
58     return m_randomGenerator.nextFloat();
59   }
60
61   public boolean nextBoolean() {
62     return m_randomGenerator.nextBit();
63   }
64 }
65
Popular Tags