C# Class HdrHistogram.Utilities.ByteBuffer

A byte buffer that tracks position and allows reads and writes of 32 and 64 bit integer values.
Mostra file Open project: HdrHistogram/HdrHistogram.NET Class Usage Examples

Public Methods

Method Description
Allocate ( byte source ) : ByteBuffer

Creates a ByteBuffer loaded with the provided byte array.

Allocate ( int bufferCapacity ) : ByteBuffer

Creates a ByteBuffer with a specified capacity in bytes.

Capacity ( ) : int

Returns the capacity of the ByteBuffer

Get ( ) : byte

Gets the current byte and advances the position by one.

GetDouble ( ) : double

Gets the double floating point number (double) at the current position, and then advances by eight.

GetInt ( ) : int

Gets the 32 bit integer (int) at the current position, and then advances by four.

GetLong ( ) : long

Gets the 64 bit integer (long) at the current position, and then advances by eight.

GetShort ( ) : short

Gets the 16 bit integer (short) at the current position, and then advances by two.

Put ( byte value ) : void

Writes a byte value to the current position, and advances the position by one.

PutDouble ( double value ) : void

Sets the bytes at the current position to the value of the passed value, and advances the position.

PutInt ( int value ) : void

Sets the bytes at the current position to the value of the passed value, and advances the position.

PutInt ( int index, int value ) : void

Sets the bytes at the provided position to the value of the passed value, and does not advance the position.

This can be useful for writing a value into an earlier placeholder e.g. a header property for storing the body length.

PutLong ( long value ) : void

Sets the bytes at the current position to the value of the passed value, and advances the position.

ReadFrom ( System source, int length ) : int

Reads from the provided System.IO.Stream, into the buffer.

Remaining ( ) : int

The remaining capacity.

Private Methods

Method Description
BlockCopy ( Array src, int srcOffset, int dstOffset, int count ) : void
BlockGet ( Array target, int targetOffset, int sourceOffset, int count ) : void
ByteBuffer ( int bufferCapacity ) : System
CheckByteArgument ( byte value, int startIndex, int bytesRequired ) : void

Checks the given argument for validity.

CheckedFromBytes ( byte value, int startIndex, int bytesToConvert ) : long

Checks the arguments for validity before calling FromBytes (which can therefore assume the arguments are valid).

FromBytes ( byte buffer, int startIndex, int bytesToConvert ) : long

Returns a value built from the specified number of bytes from the given buffer, starting at index.

Int64BitsToDouble ( long value ) : double

Converts the specified 64-bit signed integer to a double-precision floating point number. Note: the endianness of this converter does not affect the returned value.

ToArray ( ) : byte[]

Gets a copy of the internal byte array.

ToInt64 ( byte value, int startIndex ) : long

Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array.

Method Details

Allocate() public static method

Creates a ByteBuffer loaded with the provided byte array.
public static Allocate ( byte source ) : ByteBuffer
source byte The source byte array to load the buffer with.
return ByteBuffer

Allocate() public static method

Creates a ByteBuffer with a specified capacity in bytes.
public static Allocate ( int bufferCapacity ) : ByteBuffer
bufferCapacity int The capacity of the buffer in bytes
return ByteBuffer

Capacity() public method

Returns the capacity of the ByteBuffer
public Capacity ( ) : int
return int

Get() public method

Gets the current byte and advances the position by one.
public Get ( ) : byte
return byte

GetDouble() public method

Gets the double floating point number (double) at the current position, and then advances by eight.
public GetDouble ( ) : double
return double

GetInt() public method

Gets the 32 bit integer (int) at the current position, and then advances by four.
public GetInt ( ) : int
return int

GetLong() public method

Gets the 64 bit integer (long) at the current position, and then advances by eight.
public GetLong ( ) : long
return long

GetShort() public method

Gets the 16 bit integer (short) at the current position, and then advances by two.
public GetShort ( ) : short
return short

Put() public method

Writes a byte value to the current position, and advances the position by one.
public Put ( byte value ) : void
value byte The byte value to write.
return void

PutDouble() public method

Sets the bytes at the current position to the value of the passed value, and advances the position.
public PutDouble ( double value ) : void
value double The value to set the current position to.
return void

PutInt() public method

Sets the bytes at the current position to the value of the passed value, and advances the position.
public PutInt ( int value ) : void
value int The value to set the current position to.
return void

PutInt() public method

Sets the bytes at the provided position to the value of the passed value, and does not advance the position.
This can be useful for writing a value into an earlier placeholder e.g. a header property for storing the body length.
public PutInt ( int index, int value ) : void
index int The position to set the value at.
value int The value to set.
return void

PutLong() public method

Sets the bytes at the current position to the value of the passed value, and advances the position.
public PutLong ( long value ) : void
value long The value to set the current position to.
return void

ReadFrom() public method

Reads from the provided System.IO.Stream, into the buffer.
public ReadFrom ( System source, int length ) : int
source System The source stream to read from.
length int The number of bytes to read.
return int

Remaining() public method

The remaining capacity.
public Remaining ( ) : int
return int