Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.apache.mahout.common;
 
 
 
 public final class RandomWrapper extends Random {
 
   private static final long STANDARD_SEED = 0xCAFEDEADBEEFBABEL;
 
   private final RandomGenerator random;
 
   RandomWrapper() {
      = new MersenneTwister();
     .setSeed(System.currentTimeMillis() + System.identityHashCode());
   }
 
   RandomWrapper(long seed) {
      = new MersenneTwister(seed);
   }
 
   @Override
   public void setSeed(long seed) {
     // Since this will be called by the java.util.Random() constructor before we construct
     // the delegate... and because we don't actually care about the result of this for our
     // purpose:
     if ( != null) {
       .setSeed(seed);
     }
   }
 
   void resetToTestSeed() {
   }
 
     return ;
   }
 
   @Override
   protected int next(int bits) {
     // Ugh, can't delegate this method -- it's protected
     // Callers can't use it and other methods are delegated, so shouldn't matter
     throw new UnsupportedOperationException();
   }
 
   @Override
   public void nextBytes(byte[] bytes) {
     .nextBytes(bytes);
   }
 
   @Override
   public int nextInt() {
     return .nextInt();
   }
 
   @Override
   public int nextInt(int n) {
     return .nextInt(n);
   }
 
   @Override
   public long nextLong() {
     return .nextLong();
   }
 
   @Override
   public boolean nextBoolean() {
     return .nextBoolean();
   }
 
   @Override
   public float nextFloat() {
     return .nextFloat();
   }
 
   @Override
   public double nextDouble() {
     return .nextDouble();
   }
 
  public double nextGaussian() {
    return .nextGaussian();
  }
New to GrepCode? Check out our FAQ X