Files
ThingsGateway/src/Admin/ThingsGateway.NewLife.X/Collections/NonBlockingDictionary/Util.cs
2025-10-15 17:40:33 +08:00

22 lines
466 B
C#

using System.Diagnostics;
namespace System.Collections.Concurrent
{
internal static class Util
{
// returns 2^x >= size
internal static int AlignToPowerOfTwo(int size)
{
Debug.Assert(size > 0);
size--;
size |= size >> 1;
size |= size >> 2;
size |= size >> 4;
size |= size >> 8;
size |= size >> 16;
return size + 1;
}
}
}