mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 10:50:48 +08:00
22 lines
466 B
C#
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;
|
|
}
|
|
}
|
|
}
|