C# Класс Lidgren.Network.NetRandom

A fast random number generator for .NET Colin Green, January 2005
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
Instance NetRandom

Открытые методы

Метод Описание
GetSeed ( object forObject ) : int

Create a semi-random seed based on an object

NetRandom ( ) : System

Initialises a new instance using time dependent seed.

NetRandom ( int seed ) : System

Initialises a new instance using an int value as seed. This constructor signature is provided to maintain compatibility with System.Random

Next ( ) : int

Generates a random int over the range 0 to int.MaxValue-1. MaxValue is not generated in order to remain functionally equivalent to System.Random.Next(). This does slightly eat into some of the performance gain over System.Random, but not much. For better performance see: Call NextInt() for an int over the range 0 to int.MaxValue. Call NextUInt() and cast the result to an int to generate an int over the full Int32 value range including negative values.

Next ( int upperBound ) : int

Generates a random int over the range 0 to upperBound-1, and not including upperBound.

Next ( int lowerBound, int upperBound ) : int

Generates a random int over the range lowerBound to upperBound-1, and not including upperBound. upperBound must be >= lowerBound. lowerBound may be negative.

NextBool ( ) : bool

Generates a single random bit. This method's performance is improved by generating 32 bits in one operation and storing them ready for future calls.

NextBytes ( byte buffer ) : void

Fills the provided byte array with random bytes. This method is functionally equivalent to System.Random.NextBytes().

NextDouble ( ) : double

Generates a random double. Values returned are from 0.0 up to but not including 1.0.

NextInt ( ) : int

Generates a random int over the range 0 to int.MaxValue, inclusive. This method differs from Next() only in that the range is 0 to int.MaxValue and not 0 to int.MaxValue-1. The slight difference in range means this method is slightly faster than Next() but is not functionally equivalent to System.Random.Next().

NextSingle ( ) : float

Generates a random single. Values returned are from 0.0 up to but not including 1.0.

NextUInt ( ) : uint

Generates a uint. Values returned are over the full range of a uint, uint.MinValue to uint.MaxValue, inclusive. This is the fastest method for generating a single random number because the underlying random number generator algorithm generates 32 random bits that can be cast directly to a uint.

Reinitialise ( int seed ) : void

Reinitialises using an int value as a seed.

Описание методов

GetSeed() публичный Метод

Create a semi-random seed based on an object
public GetSeed ( object forObject ) : int
forObject object
Результат int

NetRandom() публичный Метод

Initialises a new instance using time dependent seed.
public NetRandom ( ) : System
Результат System

NetRandom() публичный Метод

Initialises a new instance using an int value as seed. This constructor signature is provided to maintain compatibility with System.Random
public NetRandom ( int seed ) : System
seed int
Результат System

Next() публичный Метод

Generates a random int over the range 0 to int.MaxValue-1. MaxValue is not generated in order to remain functionally equivalent to System.Random.Next(). This does slightly eat into some of the performance gain over System.Random, but not much. For better performance see: Call NextInt() for an int over the range 0 to int.MaxValue. Call NextUInt() and cast the result to an int to generate an int over the full Int32 value range including negative values.
public Next ( ) : int
Результат int

Next() публичный Метод

Generates a random int over the range 0 to upperBound-1, and not including upperBound.
public Next ( int upperBound ) : int
upperBound int
Результат int

Next() публичный Метод

Generates a random int over the range lowerBound to upperBound-1, and not including upperBound. upperBound must be >= lowerBound. lowerBound may be negative.
public Next ( int lowerBound, int upperBound ) : int
lowerBound int
upperBound int
Результат int

NextBool() публичный Метод

Generates a single random bit. This method's performance is improved by generating 32 bits in one operation and storing them ready for future calls.
public NextBool ( ) : bool
Результат bool

NextBytes() публичный Метод

Fills the provided byte array with random bytes. This method is functionally equivalent to System.Random.NextBytes().
public NextBytes ( byte buffer ) : void
buffer byte
Результат void

NextDouble() публичный Метод

Generates a random double. Values returned are from 0.0 up to but not including 1.0.
public NextDouble ( ) : double
Результат double

NextInt() публичный Метод

Generates a random int over the range 0 to int.MaxValue, inclusive. This method differs from Next() only in that the range is 0 to int.MaxValue and not 0 to int.MaxValue-1. The slight difference in range means this method is slightly faster than Next() but is not functionally equivalent to System.Random.Next().
public NextInt ( ) : int
Результат int

NextSingle() публичный Метод

Generates a random single. Values returned are from 0.0 up to but not including 1.0.
public NextSingle ( ) : float
Результат float

NextUInt() публичный Метод

Generates a uint. Values returned are over the full range of a uint, uint.MinValue to uint.MaxValue, inclusive. This is the fastest method for generating a single random number because the underlying random number generator algorithm generates 32 random bits that can be cast directly to a uint.
public NextUInt ( ) : uint
Результат uint

Reinitialise() публичный Метод

Reinitialises using an int value as a seed.
public Reinitialise ( int seed ) : void
seed int
Результат void

Описание свойств

Instance публичное статическое свойство

Gets a global NetRandom instance
public static NetRandom,Lidgren.Network Instance
Результат NetRandom