Files
HybridRow/dotnet/src/HybridRowGenerator/IntDistribution.cs
2019-08-20 11:58:29 -07:00

37 lines
1.0 KiB
C#

// ------------------------------------------------------------
// 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);
}
}
}