コード例 #1
0
        static List <PrimePosition> SplitArrayBySixBytes(byte[] byteArrayIn, int length)
        {
            var listToReturn = new List <PrimePosition>();

            for (int u = 0; u < length / 6; u++)
            {
                _positionCounter++;
                var interByte = new byte[6];
                for (int p = 0; p < 6; p++)
                {
                    interByte[p] = byteArrayIn[(6 * u) + p];
                }
                var l   = ConvertBytesToUlong(interByte);
                var pos = new PrimePosition(l, _positionCounter);
                listToReturn.Add(pos);
            }
            return(listToReturn);
        }
コード例 #2
0
        private static void CalculateLongestSequence(IEnumerable <PrimePosition> currentList)
        {
            var sortedPrimesList  = currentList.OrderBy(x => x.Position).ToList();
            var lastPrimePosition = new PrimePosition();

            foreach (var primePosition in sortedPrimesList)
            {
                if (primePosition.Prime <= lastPrimePosition.Prime)
                {
                    currentResultList.Clear();
                }
                currentResultList.Add(primePosition);
                lastPrimePosition = primePosition;
                if (CompareLists(currentResultList, resultList))
                {
                    resultList = currentResultList.ToList();
                }
            }
        }