mirror of
https://github.com/microsoft/HybridRow.git
synced 2026-01-21 10:23:13 +00:00
37 lines
1.0 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|