using System; using System.Collections.Generic; namespace Sog { public static class CoreHelper { private static readonly int MaxSequence = 1024; public static void Test() { var list = new List(); list.Sort((a, b) => 1); var v = 1024; // var id = 4096; // var idv = 32709/1024; GetSequenceCheckIndex(v, out var index1, out var index2, out var byteIndex); Console.WriteLine("c={0},index1={1},index2={2},byteIndex={3},", v, index1, index2, byteIndex); // var seq = 0; // //SetSequence(byteIndex, ref seq); // var b = CheckInSequence(byteIndex, seq); // Console.WriteLine(b); // // GetSequenceCheckIndex(1023, out var rindex1, out var index1, out var byteIndex1); // Console.WriteLine("c={0}", v); } public static void GetSequenceCheckIndex(int id, out int index1, out int index2, out int byteIndex) { var limit = 1024; index1 = id / limit; var idv = id % limit; if (idv == 0) { index1 -= 1; index2 = 31; byteIndex = 31; return; } index2 = (idv - 1) >> 5; byteIndex = (idv - 1) & 31; } public static bool CheckInSequence(int byteIndex, int sequence) { return (sequence & (1 << byteIndex)) != 0; } public static void SetSequence(int byteIndex, ref int sequence) { sequence |= (1 << byteIndex); } public static void ClearSequence(int byteIndex, ref int sequence) { sequence &= ~(1 << byteIndex); } } }