Hashing v0.1.0

Source
Ready-made seeded hash and equality callbacks for the key types a hash map or set is keyed on.

HashUint

pub func HashUint(
    value: uint,
    low: uint64,
    high: uint64
) -> uint64

The seeded hash of a uint. value, low and high are read by value. The seed is the table's, and two tables with different seeds hash the same value differently. Cannot fail. Runs in constant time and allocates nothing.

Source

Parameters

NameTypeDescription
valueuintthe value to act on
lowuint64the first seed word
highuint64the second

Returns: the value's hash under that seed

HashUint64

pub func HashUint64(
    value: uint64,
    low: uint64,
    high: uint64
) -> uint64

The seeded hash of a uint64.

Source

Parameters

NameTypeDescription
valueuint64the value to act on
lowuint64the first seed word
highuint64the second

Returns: the value's hash under that seed

HashUint32

pub func HashUint32(
    value: uint32,
    low: uint64,
    high: uint64
) -> uint64

The seeded hash of a uint32.

Source

Parameters

NameTypeDescription
valueuint32the value to act on
lowuint64the first seed word
highuint64the second

Returns: the value's hash under that seed

HashInt64

pub func HashInt64(
    value: int64,
    low: uint64,
    high: uint64
) -> uint64

The seeded hash of an int64.

Source

Parameters

NameTypeDescription
valueint64the value to act on
lowuint64the first seed word
highuint64the second

Returns: the value's hash under that seed

HashInt32

pub func HashInt32(
    value: int32,
    low: uint64,
    high: uint64
) -> uint64

The seeded hash of an int32.

Source

Parameters

NameTypeDescription
valueint32the value to act on
lowuint64the first seed word
highuint64the second

Returns: the value's hash under that seed

HashChar8

pub func HashChar8(
    value: char8,
    low: uint64,
    high: uint64
) -> uint64

The seeded hash of a char8.

Source

Parameters

NameTypeDescription
valuechar8the value to act on
lowuint64the first seed word
highuint64the second

Returns: the value's hash under that seed

HashSlice

pub func HashSlice(
    text: char8[..],
    low: uint64,
    high: uint64
) -> uint64

The seeded hash of a run of characters, which is what a string key comes to. text is borrowed and read. Two slices holding the same characters hash the same however they were built, which is what makes a text key usable at all. Runs in time proportional to the length and allocates nothing.

Source

Parameters

NameTypeDescription
textchar8[..]the bytes to hash
lowuint64the first seed word
highuint64the second

Returns: the bytes' hash under that seed

EqualsUint

pub func EqualsUint(left: uint, right: uint) -> bool

Whether two uint keys are the same.

Source

Parameters

NameTypeDescription
leftuintone of the two values
rightuintthe other

Returns: whether the two are equal

EqualsUint64

pub func EqualsUint64(left: uint64, right: uint64) -> bool

Whether two uint64 keys are the same.

Source

Parameters

NameTypeDescription
leftuint64one of the two values
rightuint64the other

Returns: whether the two are equal

EqualsUint32

pub func EqualsUint32(left: uint32, right: uint32) -> bool

Whether two uint32 keys are the same.

Source

Parameters

NameTypeDescription
leftuint32one of the two values
rightuint32the other

Returns: whether the two are equal

EqualsInt64

pub func EqualsInt64(left: int64, right: int64) -> bool

Whether two int64 keys are the same.

Source

Parameters

NameTypeDescription
leftint64one of the two values
rightint64the other

Returns: whether the two are equal

EqualsInt32

pub func EqualsInt32(left: int32, right: int32) -> bool

Whether two int32 keys are the same.

Source

Parameters

NameTypeDescription
leftint32one of the two values
rightint32the other

Returns: whether the two are equal

EqualsChar8

pub func EqualsChar8(left: char8, right: char8) -> bool

Whether two char8 keys are the same.

Source

Parameters

NameTypeDescription
leftchar8one of the two values
rightchar8the other

Returns: whether the two are equal

EqualsSlice

pub func EqualsSlice(
    left: char8[..],
    right: char8[..]
) -> bool

Whether two runs of characters hold the same characters. Both are borrowed and read. Different lengths are never equal, and two empty slices are, whatever their data pointers hold. Compares eight bytes at a time, finishing with the last eight, which may overlap words already compared; runs of four to seven bytes compare their first and last four. Only shorter runs go byte by byte.

Source

Parameters

NameTypeDescription
leftchar8[..]one of the two values
rightchar8[..]the other

Returns: whether both hold the same bytes