mirror of
https://github.com/microsoft/HybridRow.git
synced 2026-01-22 19:03:05 +00:00
Copied dotnet code from CosmosDB repository
This commit is contained in:
36
dotnet/src/HybridRowGenerator/IntDistribution.cs
Normal file
36
dotnet/src/HybridRowGenerator/IntDistribution.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
// ------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Azure.Cosmos.Serialization.HybridRowGenerator
|
||||
{
|
||||
using Microsoft.Azure.Cosmos.Core;
|
||||
using Microsoft.Azure.Cosmos.Serialization.HybridRow;
|
||||
|
||||
public class IntDistribution
|
||||
{
|
||||
private readonly int min;
|
||||
private readonly int max;
|
||||
private readonly DistributionType type;
|
||||
|
||||
public IntDistribution(int min, int max, DistributionType type = DistributionType.Uniform)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int Min => this.min;
|
||||
|
||||
public int Max => this.max;
|
||||
|
||||
public DistributionType Type => this.type;
|
||||
|
||||
public int Next(RandomGenerator rand)
|
||||
{
|
||||
Contract.Requires(this.type == DistributionType.Uniform);
|
||||
|
||||
return rand.NextInt32(this.min, this.max);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user