C# Class OpenStory.Common.IO.BoundedBuffer

Represents a moderate-performance byte buffer with a maximum capacity.
Inheritance: IDisposable
Exibir arquivo Open project: shoftee/OpenStory Class Usage Examples

Public Methods

Method Description
AppendFill ( byte buffer, int offset, int count ) : int

Takes bytes starting from an offset in an array segment and appends as many as possible to the buffer.

This method will append a maximum of count elements to the end of the buffer, starting at offset in buffer.

If there is not enough space for count elements, it will fill the remaining space with bytes from the start of buffer.

BoundedBuffer ( ) : System

Initializes a new instance of the class with no capacity.

A BoundedBuffer with no capacity is unusable. Any consumer of this class must call Reset(int) to assign a capacity before they can use it.

BoundedBuffer ( int capacity ) : System

Initializes a new instance of the BoundedBuffer class with a maximum capacity.

Dispose ( ) : void
ExtractAndReset ( int newCapacity ) : byte[]

Extracts the data from the BoundedBuffer and prepares it for the new data.

Reset ( int newCapacity ) : void

Prepares the buffer for new data.

Private Methods

Method Description
AppendInternal ( byte buffer, int offset, int requested ) : int
Dispose ( bool disposing ) : void

Virtual dispose method. When overriding, call the base implementation before your logic.

GetCapacityIsNonPositiveException ( int capacity ) : ArgumentOutOfRangeException
GetCountIsNonPositiveException ( int count ) : ArgumentOutOfRangeException
GetNewCapacityIsNegativeException ( int newCapacity ) : ArgumentOutOfRangeException
GetOffsetIsNegativeException ( int offset ) : ArgumentOutOfRangeException
ResetInternal ( int newCapacity ) : void
ThrowIfDisposed ( ) : void

Throws a new ObjectDisposedException if the current object is disposed.

Method Details

AppendFill() public method

Takes bytes starting from an offset in an array segment and appends as many as possible to the buffer.
This method will append a maximum of count elements to the end of the buffer, starting at offset in buffer.

If there is not enough space for count elements, it will fill the remaining space with bytes from the start of buffer.

Thrown if is . Thrown if is negative or is non-positive. Thrown if the array segment given by the and parameters falls outside of the given array's bounds.
public AppendFill ( byte buffer, int offset, int count ) : int
buffer byte The array to read from.
offset int The start of the segment.
count int The number of bytes to append.
return int

BoundedBuffer() public method

Initializes a new instance of the class with no capacity.
A BoundedBuffer with no capacity is unusable. Any consumer of this class must call Reset(int) to assign a capacity before they can use it.
public BoundedBuffer ( ) : System
return System

BoundedBuffer() public method

Initializes a new instance of the BoundedBuffer class with a maximum capacity.
The exception is thrown if is non-positive.
public BoundedBuffer ( int capacity ) : System
capacity int The maximum capacity to assign.
return System

Dispose() public method

public Dispose ( ) : void
return void

ExtractAndReset() public method

Extracts the data from the BoundedBuffer and prepares it for the new data.
Thrown if is negative.
public ExtractAndReset ( int newCapacity ) : byte[]
newCapacity int The new capacity for the .
return byte[]

Reset() public method

Prepares the buffer for new data.
Thrown if is negative.
public Reset ( int newCapacity ) : void
newCapacity int The new capacity for the buffer.
return void