Line | |
---|
1 | #region License Information
|
---|
2 | /*
|
---|
3 | * This file is part of SimSharp which is licensed under the MIT license.
|
---|
4 | * See the LICENSE file in the project root for more information.
|
---|
5 | */
|
---|
6 | #endregion
|
---|
7 |
|
---|
8 | using System;
|
---|
9 |
|
---|
10 | namespace SimSharp {
|
---|
11 | public class SystemRandom : IRandom {
|
---|
12 | private Random random;
|
---|
13 |
|
---|
14 | public SystemRandom() {
|
---|
15 | random = new Random();
|
---|
16 | }
|
---|
17 |
|
---|
18 | public SystemRandom(int seed) {
|
---|
19 | random = new Random(seed);
|
---|
20 | }
|
---|
21 | public int Next() {
|
---|
22 | return random.Next();
|
---|
23 | }
|
---|
24 |
|
---|
25 | public int Next(int upperBound) {
|
---|
26 | return random.Next(upperBound);
|
---|
27 | }
|
---|
28 |
|
---|
29 | public int Next(int lowerBound, int upperBound) {
|
---|
30 | return random.Next(lowerBound, upperBound);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public double NextDouble() {
|
---|
34 | return random.NextDouble();
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void Reinitialise(int seed) {
|
---|
38 | random = new Random(seed);
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.