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

checkValues() private static method

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

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

            //if (values.Length != lengths.Sum(x => (int)x))
            if (IEnum.Sum(lengths) != values.Length)
                throw new ArgumentException("Number of values does not match code length sum.");

            return values;
        }