All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.msv.generator.Rand Maven / Gradle / Ivy

There is a newer version: 2022.7
Show newest version
/*
 * @(#)$Id: Rand.java 517 2001-05-09 21:09:03Z Bear $
 *
 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * This software is the proprietary information of Sun Microsystems, Inc.  
 * Use is subject to license terms.
 * 
 */
package com.sun.msv.generator;

import java.util.Random;

/**
 * creates random integer.
 * 
 * @author Kohsuke KAWAGUCHI
 */
public interface Rand
{
	int next();
	
	/**
	 * uniform distribution of [0,x).
	 * 
	 * @author Kohsuke KAWAGUCHI
	 */
	public static class UniformRand implements Rand
	{
		private final Random rand;
		private int max;
		
		public UniformRand( Random rand, int max ) {
			this.rand = rand;
			this.max = max;
		}
		public int next() {
			return rand.nextInt(max);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy