public int[] ReadValues(long bitsToRead, IBitReader bitReader) { var arrayLength = bitReader.ReadNBits(32); var values = new List <int>(); var encodedValue = new TableEncodedValue(); for (int i = 0; i < arrayLength; i++) { int numberOf1Before0 = 0; while (bitReader.ReadNBits(1) != 0) { numberOf1Before0++; } if (numberOf1Before0 == 0) { values.Add(0); } else { encodedValue.NumberOf1Before0 = numberOf1Before0; encodedValue.ValueAfter0 = (int)bitReader.ReadNBits(numberOf1Before0); values.Add(TableValueEncoding.DecodeValue(encodedValue)); } } return(values.ToArray()); }