C# Class fCraft.BufferUtil

Provides utility methods for working with byte arrays and pointers.
Show file Open project: fragmer/fCraft Class Usage Examples

Public Methods

Method Description
MemCpy ( [ src, [ dest, int len ) : void

Copies contents of src buffer to dest buffer, as efficiently as possible.

MemSet ( [ array, byte value ) : void

Fills the entire given byte array with a specified byte value, as efficiently as possible.

MemSet ( [ array, byte value, int startIndex, int length ) : void

Fills a section of the given byte array with a specified byte value, as efficiently as possible.

ReadAll ( [ source, [ destination ) : void

Reads a number of bytes from source that matches the length of destination byte array.

WriteAll ( [ source, [ destination ) : void

Writes contents of given byte array to a stream, in chunks of at most 512 MiB. Works around an overflow in BufferedStream.Write(byte[]) that happens on 1 GiB+ writes.

Private Methods

Method Description
MemCmp ( [ data, int offset, [ value ) : bool

Method Details

MemCpy() public static method

Copies contents of src buffer to dest buffer, as efficiently as possible.
public static MemCpy ( [ src, [ dest, int len ) : void
src [ Source array/pointer.
dest [ Destination array/pointer.
len int Number of bytes to copy.
return void

MemSet() public static method

Fills the entire given byte array with a specified byte value, as efficiently as possible.
array is null.
public static MemSet ( [ array, byte value ) : void
array [ Array to work with.
value byte Value to assign to each byte of the array.
return void

MemSet() public static method

Fills a section of the given byte array with a specified byte value, as efficiently as possible.
array is null. length is negative; startIndex is negative; /// or if (length+startIndex) is greater than array length.
public static MemSet ( [ array, byte value, int startIndex, int length ) : void
array [ Array to work with.
value byte Value to assign to each byte of the array.
startIndex int Index of the first byte that should be set.
length int Number of bytes of the array to set.
return void

ReadAll() public static method

Reads a number of bytes from source that matches the length of destination byte array.
source or destination is null. The end of stream is reached before destination array was filled.
public static ReadAll ( [ source, [ destination ) : void
source [ Stream to read from.
destination [ Byte array to write to. Length of this array is used.
return void

WriteAll() public static method

Writes contents of given byte array to a stream, in chunks of at most 512 MiB. Works around an overflow in BufferedStream.Write(byte[]) that happens on 1 GiB+ writes.
source or destination is null.
public static WriteAll ( [ source, [ destination ) : void
source [ Byte array to read from. Must not be null.
destination [ Stream to write to. Must not be null.
return void