Struct xxHash3.StreamingState
Type used to compute hash based on multiple data feed
Namespace: Unity.Collections
Syntax
public struct StreamingState
Remarks
Allow to feed the internal hashing accumulators with data through multiple calls to Update(Void*, Int32), then retrieving the final hash value using DigestHash64() or DigestHash128(). More info about how to use this class in its constructor.
Constructors
StreamingState(Boolean, UInt64)
Create a StreamingState object, ready to be used with the streaming API
Declaration
public StreamingState(bool isHash64, ulong seed = 0UL)
Parameters
Type | Name | Description |
---|---|---|
Boolean | isHash64 | true if we are computing a 64bits hash value, false if we are computing a 128bits one |
UInt64 | seed | A seed value to be used to compute the hash, default is 0 |
Remarks
Once the object is constructed, you can call the Update(Void*, Int32) method as many times as you want to accumulate data to hash. When all the data has been sent, call DigestHash64() or DigestHash128() to retrieve the corresponding key, the xxHash3.StreamingState instance will then be reset, using the same hash key size and same Seed in order to be ready to be used again.
Methods
DigestHash128()
Compute the 128bits value based on all the data that have been accumulated
Declaration
public uint4 DigestHash128()
Returns
Type | Description |
---|---|
uint4 | The hash value |
DigestHash64()
Compute the 64bits value based on all the data that have been accumulated
Declaration
public uint2 DigestHash64()
Returns
Type | Description |
---|---|
uint2 | The hash value |
Reset(Boolean, UInt64)
Reset the state of the streaming instance using the given seed value.
Declaration
public void Reset(bool isHash64, ulong seed = 0UL)
Parameters
Type | Name | Description |
---|---|---|
Boolean | isHash64 | |
UInt64 | seed | The seed value to alter the computed hash value from |
Remarks
Call this method to start a new streaming session based on this instance
Update(Void*, Int32)
Add some data to be hashed
Declaration
public void Update(void *input, int length)
Parameters
Type | Name | Description |
---|---|---|
Void* | input | The memory buffer, can't be null |
Int32 | length | The length of the data to accumulate, can be zero |
Remarks
This API allows you to feed very small data to be hashed, avoiding you to accumulate them in a big buffer, then computing the hash value from.
Update<T>(in T)
Add the contents of input struct to the hash.
Declaration
public void Update<T>(in T input)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T | input | The input struct that will be hashed |
Type Parameters
Name | Description |
---|---|
T | The input type. |
Remarks
This API allows you to feed very small data to be hashed, avoiding you to accumulate them in a big buffer, then computing the hash value from.