Class xxHash3 | Collections | 0.14.0-preview.16
docs.unity3d.com
    Show / Hide Table of Contents

    Class xxHash3

    A feature complete hashing API based on xxHash3 (https://github.com/Cyan4973/xxHash)

    Inheritance
    Object
    xxHash3
    Namespace: Unity.Collections
    Syntax
    public static class xxHash3
    Remarks

    Features:

    • Compute 64bits or 128bits hash keys, based on a private key, with an optional given seed value.
    • Hash on buffer (with or without a ulong based seed value)
    • Hash on buffer while copying the data to a destination
    • Use instances of xxHash3.StreamingState to accumulate data to hash in multiple calls, suited for small data, then retrieve the hash key at the end.
    • xxHash3 has several implementation based on the size to hash to ensure best performances
    • We currently have two implementations:
    • A generic one based on Unity.Mathematics, that should always be executed compiled with Burst.
    • An AVX2 based implementation for platforms supporting it, using Burst intrinsics.
    • Whether or not the call site is compiled with burst, the hashing function will be executed by Burst() to ensure optimal performance. () Only when the hashing size justifies such transition.

    Methods

    Hash128(Void*, Int64)

    Compute a 128bits hash of a memory region

    Declaration
    public static uint4 Hash128(void *input, long length)
    Parameters
    Type Name Description
    Void* input

    The memory buffer, can't be null

    Int64 length

    The length of the memory buffer, can be zero

    Returns
    Type Description
    Unity.Mathematics.uint4

    The hash result

    Hash128(Void*, Int64, UInt64)

    Compute a 128bits hash of a memory region using a given seed value

    Declaration
    public static uint4 Hash128(void *input, long length, ulong seed)
    Parameters
    Type Name Description
    Void* input

    The memory buffer, can't be null

    Int64 length

    The length of the memory buffer, can be zero

    UInt64 seed

    The seed value to alter the hash computation from

    Returns
    Type Description
    Unity.Mathematics.uint4

    The hash result

    Hash128(Void*, Void*, Int64)

    Compute a 128bits hash while copying the data to a destination buffer

    Declaration
    public static uint4 Hash128(void *input, void *destination, long length)
    Parameters
    Type Name Description
    Void* input

    The memory buffer to compute the hash and copy from, can't be null

    Void* destination

    The destination buffer, can't be null and must be at least big enough to match the input's length

    Int64 length

    The length of the memory buffer, can be zero

    Returns
    Type Description
    Unity.Mathematics.uint4

    The hash result

    Remarks

    Use this API to avoid a double memory scan in situations where the hash as to be compute and the data copied at the same time. Performances improvements vary between 30-50% on big data.

    Hash128(Void*, Void*, Int64, UInt64)

    Compute a 128bits hash while copying the data to a destination buffer using a given seed value

    Declaration
    public static uint4 Hash128(void *input, void *destination, long length, ulong seed)
    Parameters
    Type Name Description
    Void* input

    The memory buffer to compute the hash and copy from, can't be null

    Void* destination

    The destination buffer, can't be null and must be at least big enough to match the input's length

    Int64 length

    The length of the memory buffer, can be zero

    UInt64 seed

    The seed value to alter the hash computation from

    Returns
    Type Description
    Unity.Mathematics.uint4

    The hash result

    Hash64(Void*, Int64)

    Compute a 64bits hash of a memory region

    Declaration
    public static uint2 Hash64(void *input, long length)
    Parameters
    Type Name Description
    Void* input

    The memory buffer, can't be null

    Int64 length

    The length of the memory buffer, can be zero

    Returns
    Type Description
    Unity.Mathematics.uint2

    The hash result

    Hash64(Void*, Int64, UInt64)

    Compute a 64bits hash of a memory region using a given seed value

    Declaration
    public static uint2 Hash64(void *input, long length, ulong seed)
    Parameters
    Type Name Description
    Void* input

    The memory buffer, can't be null

    Int64 length

    The length of the memory buffer, can be zero

    UInt64 seed

    The seed value to alter the hash computation from

    Returns
    Type Description
    Unity.Mathematics.uint2

    The hash result

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023