[−][src]Crate morton_encoding
morton_encoding
is a crate that helps interleave the bits of numbers,
(called "co-ordinates" in the source code)
thereby creating a so-called "Morton encoding" (also known as a
"Z-order encoding") in whose final result ("Key")
all bits of the same significance are together.
This is helpful for linearising the points of data structures whilst preserving
some measure of locality. Z-order encoding isn't as good at preserving
locality as Hilbert encoding, but it is much easier to compute.
Contents
The functions contained herein are broadly split into four categories:
- "Bloating functions", that interleave a number's bits with zeroes;
- "Shrinking functions", that perform the opposite operation;
- "Morton encoding functions", that interleave some numbers' bits with each other;
- "Morton decoding functions", that perform the opposite operation.
For more detailed information, please refer to each individual function's documentation.
std
vs no_std
This crate (or its documentation, in any event) has currently been compiled with std
on, meaning that it can interleave arbitrary amounts of arbitrarily large integers, with no need for the user to define his/her own integer types if the result is larger than 128 bits.
Traits
ValidKey | Guarantees that a given data structure is suitable for a Morton Key. |
Functions
bloat | "Bloats" a given number, interleaving its bits with an automatically-computed number of zeroes. |
bloat_custom | "Bloats" a given number, interleaving its bits with a user-provided number of zeroes. |
bloat_custom_biguint | "Bloats" a given number to an arbitrarily large BigUint. |
bloat_custom_checked | "Bloats" a given number, interleaving its bits with a user-provided number of zeroes. Returns an |
morton_decode | Receives a |
morton_decode_biguint | Receives a |
morton_decode_u16_2d | Decodes a |
morton_decode_u16_3d | Decodes a |
morton_decode_u16_4d | Decodes a |
morton_decode_u16_5d | Decodes a |
morton_decode_u16_6d | Decodes a |
morton_decode_u16_7d | Decodes a |
morton_decode_u16_8d | Decodes a |
morton_decode_u32_2d | Decodes a |
morton_decode_u32_3d | Decodes a |
morton_decode_u32_4d | Decodes a |
morton_decode_u64_2d | Decodes a |
morton_decode_u8_2d | Decodes a |
morton_decode_u8_3d | Decodes a |
morton_decode_u8_4d | Decodes a |
morton_decode_u8_5d | Decodes a |
morton_decode_u8_6d | Decodes a |
morton_decode_u8_7d | Decodes a |
morton_decode_u8_8d | Decodes a |
morton_decode_u8_9d | Decodes a |
morton_decode_u8_10d | Decodes a |
morton_decode_u8_11d | Decodes a |
morton_decode_u8_12d | Decodes a |
morton_decode_u8_13d | Decodes a |
morton_decode_u8_14d | Decodes a |
morton_decode_u8_15d | Decodes a |
morton_decode_u8_16d | Decodes a |
morton_encode | Receives an iterator of |
morton_encode_biguint | Receives an iterator of |
morton_encode_checked | Receives an iterator of |
morton_encode_u16_2d | Encodes an array of 2 |
morton_encode_u16_3d | Encodes an array of 3 |
morton_encode_u16_4d | Encodes an array of 4 |
morton_encode_u16_5d | Encodes an array of 5 |
morton_encode_u16_6d | Encodes an array of 6 |
morton_encode_u16_7d | Encodes an array of 7 |
morton_encode_u16_8d | Encodes an array of 8 |
morton_encode_u32_2d | Encodes an array of 2 |
morton_encode_u32_3d | Encodes an array of 3 |
morton_encode_u32_4d | Encodes an array of 4 |
morton_encode_u64_2d | Encodes an array of 2 |
morton_encode_u8_2d | Encodes an array of 2 |
morton_encode_u8_3d | Encodes an array of 3 |
morton_encode_u8_4d | Encodes an array of 4 |
morton_encode_u8_5d | Encodes an array of 5 |
morton_encode_u8_6d | Encodes an array of 6 |
morton_encode_u8_7d | Encodes an array of 7 |
morton_encode_u8_8d | Encodes an array of 8 |
morton_encode_u8_9d | Encodes an array of 9 |
morton_encode_u8_10d | Encodes an array of 10 |
morton_encode_u8_11d | Encodes an array of 11 |
morton_encode_u8_12d | Encodes an array of 12 |
morton_encode_u8_13d | Encodes an array of 13 |
morton_encode_u8_14d | Encodes an array of 14 |
morton_encode_u8_15d | Encodes an array of 15 |
morton_encode_u8_16d | Encodes an array of 16 |
nz | A convenience function for persuading the compiler that a non-zero value is, in fact, non-zero. |
shrink | "Shrinks" a given number, only keeping an automatically-computed amount of its bits. |
shrink_custom | "Shrinks" a given number, only keeping a user-provided amount of its bits. |
shrink_custom_biguint | "Shrinks" a given number from an arbitrarily large BigUint. |
shrink_custom_checked | "Shrinks" a given number, only keeping a user-provided amount of its bits. Returns an |
tobuint | A convenience function for converting primitive values to BigUints. Will fail to compile if called with a literal that's not explicitly declared as unsigned. |