namespace Standart.Hash.xxHash
{
using System.Diagnostics;
public static partial class xxHash64
{
///
/// Compute xxHash for the data byte array
///
/// The source of data
/// The length of the data for hashing
/// The seed number
/// hash
public static unsafe ulong ComputeHash(byte[] data, int length, ulong seed = 0)
{
Debug.Assert(data != null);
Debug.Assert(length >= 0);
Debug.Assert(length <= data.Length);
fixed (byte* pData = &data[0])
{
return UnsafeComputeHash(pData, length, seed);
}
}
///
/// Compute xxHash for the data byte array
///
/// The source of data
/// The length of the data for hashing
/// The seed number
/// hash
public static unsafe ulong ComputeHash(byte[] data, int offset, int length, ulong seed = 0)
{
Debug.Assert(data != null);
Debug.Assert(length >= 0);
Debug.Assert(offset < data.Length);
Debug.Assert(length <= data.Length - offset);
fixed (byte* pData = &data[0 + offset])
{
return UnsafeComputeHash(pData, length, seed);
}
}
///
/// Compute xxHash for the data byte array
///
/// The source of data
/// The seed number
/// hash
public static unsafe ulong ComputeHash(System.ArraySegment data, ulong seed = 0)
{
Debug.Assert(data != null);
return ComputeHash(data.Array, data.Offset, data.Count, seed);
}
}
}