Photon Fusion 2.1.1

ElementReaderWriterUnmanaged< T, TWordCount > Struct Template Reference

Provides methods to read and write unmanaged elements with a specified stride. More...

Inherits IElementReaderWriter< T >.

Public Member Functions

int GetElementHashCode (T element)
 Gets the hash code of the specified element.
int GetElementWordCount ()
 Gets the stride (in bytes) between elements.
unsafe T Read (byte *data, int index)
 Reads an element from the specified data at the given index.
Read (ReadOnlySpan< byte > data)
unsafe ref T ReadRef (byte *data, int index)
 Reads a reference to an element from the specified data at the given index.
ref T ReadRef (Span< byte > data)
unsafe void Write (byte *data, int index, T element)
 Writes an element to the specified data at the given index.
void Write (Span< byte > data, T element)

Static Public Member Functions

static IElementReaderWriter< T > GetInstance ()
 Returns an instance of the reader/writer.

Detailed Description

Provides methods to read and write unmanaged elements with a specified stride.

Template Parameters
TThe type of the unmanaged element.
TWordCount
Type Constraints
T :unmanaged 
TWordCount :unmanaged 
TWordCount :IMetaConstant 

Member Function Documentation

◆ GetElementHashCode()

int GetElementHashCode ( T element)

Gets the hash code of the specified element.

Parameters
elementThe element for which to get the hash code.
Returns
The hash code of the element.

Implements IElementReaderWriter< T >.

◆ GetElementWordCount()

int GetElementWordCount ( )

Gets the stride (in bytes) between elements.

Returns
The stride between elements.

Implements IElementReaderWriter< T >.

◆ Read()

unsafe T Read ( byte * data,
int index )

Reads an element from the specified data at the given index.

Parameters
dataA pointer to the data.
indexThe index of the element to read.
Returns
The element read from the data.

Implements IElementReaderWriter< T >.

◆ ReadRef()

unsafe ref T ReadRef ( byte * data,
int index )

Reads a reference to an element from the specified data at the given index.

Parameters
dataA pointer to the data.
indexThe index of the element to read.
Returns
A reference to the element read from the data.

Implements IElementReaderWriter< T >.

◆ Write()

unsafe void Write ( byte * data,
int index,
T element )

Writes an element to the specified data at the given index.

Parameters
dataA pointer to the data.
indexThe index at which to write the element.
elementThe element to write.

Implements IElementReaderWriter< T >.