Class FibonacciHash
Inheritance
Namespace: GDX.Mathematics
Syntax
public static class FibonacciHash
Methods
| Improve this Doc View SourceGetIndexFromHash(Int32, Byte)
Takes the hash
and multiplies it by 2^32 divided by the golden ratio,
then right shifts it by shift
to fit within a given power-of-two size.
Declaration
public static int GetIndexFromHash(int hash, byte shift)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | hash | The key to find an index for. |
System.Byte | shift | How far to right shift in order to fit within a given power-of-two size. |
Returns
Type | Description |
---|---|
System.Int32 | The index to store the |
GetIndexFromHash(Int32, Int32)
Takes the hash
and finds an index within the provided pow2Length
range with
Fibonacci hashing.
Declaration
public static int GetIndexFromHash(int hash, int pow2Length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | hash | The hash to find an index for. |
System.Int32 | pow2Length | The power-of-two array length to find an index within. |
Returns
Type | Description |
---|---|
System.Int32 |
GetRightShiftFromPow2Length(Int32)
Takes a 32-bit length equal to a power of two, and returns how many spaces another 32-bit int would need to shift in order to be a valid index within an array of that length.
Declaration
public static byte GetRightShiftFromPow2Length(int pow2Length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pow2Length | A 32-bit int equal to a power of two. |
Returns
Type | Description |
---|---|
System.Byte | How many spaces a 32-bit int would need to shift in order to be a valid index within
|