Hashing v0.1.0
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.
Parameters
| Name | Type | Description |
|---|---|---|
value | uint | the value to act on |
low | uint64 | the first seed word |
high | uint64 | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
value | uint64 | the value to act on |
low | uint64 | the first seed word |
high | uint64 | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
value | uint32 | the value to act on |
low | uint64 | the first seed word |
high | uint64 | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
value | int64 | the value to act on |
low | uint64 | the first seed word |
high | uint64 | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
value | int32 | the value to act on |
low | uint64 | the first seed word |
high | uint64 | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
value | char8 | the value to act on |
low | uint64 | the first seed word |
high | uint64 | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
text | char8[..] | the bytes to hash |
low | uint64 | the first seed word |
high | uint64 | the second |
Returns: the bytes' hash under that seed
EqualsUint
pub func EqualsUint(left: uint, right: uint) -> bool
Whether two uint keys are the same.
Parameters
| Name | Type | Description |
|---|---|---|
left | uint | one of the two values |
right | uint | the other |
Returns: whether the two are equal
EqualsUint64
pub func EqualsUint64(left: uint64, right: uint64) -> bool
Whether two uint64 keys are the same.
Parameters
| Name | Type | Description |
|---|---|---|
left | uint64 | one of the two values |
right | uint64 | the other |
Returns: whether the two are equal
EqualsUint32
pub func EqualsUint32(left: uint32, right: uint32) -> bool
Whether two uint32 keys are the same.
Parameters
| Name | Type | Description |
|---|---|---|
left | uint32 | one of the two values |
right | uint32 | the other |
Returns: whether the two are equal
EqualsInt64
pub func EqualsInt64(left: int64, right: int64) -> bool
Whether two int64 keys are the same.
Parameters
| Name | Type | Description |
|---|---|---|
left | int64 | one of the two values |
right | int64 | the other |
Returns: whether the two are equal
EqualsInt32
pub func EqualsInt32(left: int32, right: int32) -> bool
Whether two int32 keys are the same.
Parameters
| Name | Type | Description |
|---|---|---|
left | int32 | one of the two values |
right | int32 | the other |
Returns: whether the two are equal
EqualsChar8
pub func EqualsChar8(left: char8, right: char8) -> bool
Whether two char8 keys are the same.
Parameters
| Name | Type | Description |
|---|---|---|
left | char8 | one of the two values |
right | char8 | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
left | char8[..] | one of the two values |
right | char8[..] | the other |
Returns: whether both hold the same bytes