BF2Statistics.Utilities.Crc16.BuildCrcTable C# (CSharp) Method

BuildCrcTable() private method

Builds the Crc table programatically with the given polynomial
private BuildCrcTable ( ushort polynomial ) : void
polynomial ushort
return void
        private void BuildCrcTable(ushort polynomial)
        {
            ushort value;
            ushort temp;

            // Build standard Crc16 Table
            CrcTable = new ushort[256];
            for (ushort i = 0; i < 256; ++i)
            {
                value = 0;
                temp = i;
                for (byte j = 0; j < 8; ++j)
                {
                    if (((value ^ temp) & 0x0001) != 0)
                        value = (ushort)((value >> 1) ^ polynomial);
                    else
                        value >>= 1;

                    temp >>= 1;
                }

                CrcTable[i] = value;
            }
        }