Class BitWriter
Writes individual bits sequentially using a System.IO.BinaryWriter
.
public class BitWriter : IDisposable
Implements:
System.IDisposable
Properties
Position
Gets the current position (in bits, starting at 0).
public int Position { get; protected set; }
Fields
binaryWriter
protected BinaryWriter binaryWriter
byteBuffer
protected byte byteBuffer
bitMask
protected byte bitMask
Methods
Write(bool)
Writes a boolean value where
<i>true</i> is represented as 1
and
<i>false</i> is represented as 0
.
public void Write(bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | The value to write. |
Write(IEnumerable<bool>)
Writes a series of boolean values where
<i>true</i> is represented as 1
and
<i>false</i> is represented as 0
.
public void Write(IEnumerable<bool> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Boolean> | values | An enumerable collection of values to write. |
Write(int, int)
Writes an unsigned integer using <i>base2</i> encoding.
public void Write(int value, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value to write. |
System.Int32 | length | The number of bits used to encode the value. |
Write(uint, int)
Writes an unsigned integer using <i>base2</i> encoding.
public void Write(uint value, int length)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | value | The value to write. |
System.Int32 | length | The number of bits used to encode the value. |
Write(long, int)
Writes an unsigned long integer using <i>base2</i> encoding.
public void Write(long value, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value to write. |
System.Int32 | length | The number of bits used to encode the value. |
Write(ulong, int)
Writes an unsigned long integer using <i>base2</i> encoding.
public void Write(ulong value, int length)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | value | The value to write. |
System.Int32 | length | The number of bits used to encode the value. |
WriteFib(int)
Writes an unsigned integer in Fibonacci encoding.
public void WriteFib(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value to write. |
Flush()
Flushes whatever is in the buffer to the underlying binary writer.
public void Flush()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Reset()
Resets the bitMask
and clears the byteBuffer
.
protected void Reset()
AdvancePosition()
Moves the position to the next bit; flushing and reseting if needed.
protected void AdvancePosition()
ComputeFib(uint)
protected static uint ComputeFib(uint value)
Returns
System.UInt32
Parameters
Type | Name |
---|---|
System.UInt32 | value |
Implements
System.IDisposable