FluxJpeg.Core.JpegHuffmanTable.checkLengths C# (CSharp) Method

checkLengths() private static method

private static checkLengths ( short lengths ) : short[]
lengths short
return short[]
        private static short[] checkLengths(short[] lengths)
        {
            if (lengths == null || lengths.Length > 16)
                throw new ArgumentException("Length array is null or too long.");

            //if (lengths.Any(x => x < 0))
            if (IEnum.Any(lengths, x => x < 0))
                throw new ArgumentException("Negative values cannot appear in the length array.");

            for (int i = 0; i < lengths.Length; i++)
            {
                if (lengths[i] > ((1 << (i + 1)) - 1))
                    throw new ArgumentException(
                        string.Format("Invalid number of codes for code length {0}", (i + 1).ToString()));
            }

            return lengths;
        }