EonaCat.Network/EonaCat.Network/System/Quic/Infrastructure/NumberSpace.cs

38 lines
751 B
C#

using System;
namespace EonaCat.Quic.Infrastructure
{
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
public class NumberSpace
{
private readonly uint _max = uint.MaxValue;
private uint _n = 0;
public NumberSpace()
{
}
public NumberSpace(uint max)
{
_max = max;
}
public bool IsMax()
{
return _n == _max;
}
public uint Get()
{
if (_n >= _max)
{
return 0;
}
_n++;
return _n;
}
}
}