public static BitTwiddler FromBytes(IEnumerator <sbyte> bytes, int length) { int byteCount = CorrectByteCount(length); var result = BitTwiddler.WithByteCount(byteCount); for (int i = 0; i < byteCount; i++) { bytes.MoveNext(); result = result.SetSignedByte(bytes.Current); } return(result); }
public static BitTwiddler FromBytes(IEnumerator <byte> bytes, int length) { if (length < 0) { throw new ArgumentOutOfRangeException("length"); } int byteCount = Math.Min(length, MaxByteCount); var result = BitTwiddler.WithByteCount(byteCount); for (int i = 0; i < byteCount; i++) { bytes.MoveNext(); result = result.SetByte(bytes.Current); } return(result); }
public static BitTwiddler FromBytes(sbyte[] bytes, int index, int length) { if (index < 0 || index > bytes.Length) { throw new ArgumentOutOfRangeException("index"); } if (length < 0 || index + length > bytes.Length) { throw new ArgumentOutOfRangeException("length"); } int byteCount = Math.Min(length, MaxByteCount); var result = BitTwiddler.WithByteCount(byteCount); for (int i = 0; i < byteCount; i++) { result = result.SetSignedByte(bytes[i], i); } return(result); }