[][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.

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.

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 Option.

morton_decode

Receives a Key value and returns an iterator of Coor values that were decoded from it.

morton_decode_biguint

Receives a BigUint value and returns an iterator of BigUint values that were decoded from it.

morton_decode_u16_2d

Decodes a u32 value, producing an array of 2 u16 values ([u16; 2]) as the result.

morton_decode_u16_3d

Decodes a u64 value, producing an array of 3 u16 values ([u16; 3]) as the result.

morton_decode_u16_4d

Decodes a u64 value, producing an array of 4 u16 values ([u16; 4]) as the result.

morton_decode_u16_5d

Decodes a u128 value, producing an array of 5 u16 values ([u16; 5]) as the result.

morton_decode_u16_6d

Decodes a u128 value, producing an array of 6 u16 values ([u16; 6]) as the result.

morton_decode_u16_7d

Decodes a u128 value, producing an array of 7 u16 values ([u16; 7]) as the result.

morton_decode_u16_8d

Decodes a u128 value, producing an array of 8 u16 values ([u16; 8]) as the result.

morton_decode_u32_2d

Decodes a u64 value, producing an array of 2 u32 values ([u32; 2]) as the result.

morton_decode_u32_3d

Decodes a u128 value, producing an array of 3 u32 values ([u32; 3]) as the result.

morton_decode_u32_4d

Decodes a u128 value, producing an array of 4 u32 values ([u32; 4]) as the result.

morton_decode_u64_2d

Decodes a u128 value, producing an array of 2 u64 values ([u64; 2]) as the result.

morton_decode_u8_2d

Decodes a u16 value, producing an array of 2 u8 values ([u8; 2]) as the result.

morton_decode_u8_3d

Decodes a u32 value, producing an array of 3 u8 values ([u8; 3]) as the result.

morton_decode_u8_4d

Decodes a u32 value, producing an array of 4 u8 values ([u8; 4]) as the result.

morton_decode_u8_5d

Decodes a u64 value, producing an array of 5 u8 values ([u8; 5]) as the result.

morton_decode_u8_6d

Decodes a u64 value, producing an array of 6 u8 values ([u8; 6]) as the result.

morton_decode_u8_7d

Decodes a u64 value, producing an array of 7 u8 values ([u8; 7]) as the result.

morton_decode_u8_8d

Decodes a u64 value, producing an array of 8 u8 values ([u8; 8]) as the result.

morton_decode_u8_9d

Decodes a u128 value, producing an array of 9 u8 values ([u8; 9]) as the result.

morton_decode_u8_10d

Decodes a u128 value, producing an array of 10 u8 values ([u8; 10]) as the result.

morton_decode_u8_11d

Decodes a u128 value, producing an array of 11 u8 values ([u8; 11]) as the result.

morton_decode_u8_12d

Decodes a u128 value, producing an array of 12 u8 values ([u8; 12]) as the result.

morton_decode_u8_13d

Decodes a u128 value, producing an array of 13 u8 values ([u8; 13]) as the result.

morton_decode_u8_14d

Decodes a u128 value, producing an array of 14 u8 values ([u8; 14]) as the result.

morton_decode_u8_15d

Decodes a u128 value, producing an array of 15 u8 values ([u8; 15]) as the result.

morton_decode_u8_16d

Decodes a u128 value, producing an array of 16 u8 values ([u8; 16]) as the result.

morton_encode

Receives an iterator of Coor values and encodes them all in a Key value.

morton_encode_biguint

Receives an iterator of Coor values and encodes them all in a BigUint.

morton_encode_checked

Receives an iterator of Coor values and encodes them all in a Option<Key> value.

morton_encode_u16_2d

Encodes an array of 2 u16 values ([u16; 2]), producing a u32 value as the result.

morton_encode_u16_3d

Encodes an array of 3 u16 values ([u16; 3]), producing a u64 value as the result.

morton_encode_u16_4d

Encodes an array of 4 u16 values ([u16; 4]), producing a u64 value as the result.

morton_encode_u16_5d

Encodes an array of 5 u16 values ([u16; 5]), producing a u128 value as the result.

morton_encode_u16_6d

Encodes an array of 6 u16 values ([u16; 6]), producing a u128 value as the result.

morton_encode_u16_7d

Encodes an array of 7 u16 values ([u16; 7]), producing a u128 value as the result.

morton_encode_u16_8d

Encodes an array of 8 u16 values ([u16; 8]), producing a u128 value as the result.

morton_encode_u32_2d

Encodes an array of 2 u32 values ([u32; 2]), producing a u64 value as the result.

morton_encode_u32_3d

Encodes an array of 3 u32 values ([u32; 3]), producing a u128 value as the result.

morton_encode_u32_4d

Encodes an array of 4 u32 values ([u32; 4]), producing a u128 value as the result.

morton_encode_u64_2d

Encodes an array of 2 u64 values ([u64; 2]), producing a u128 value as the result.

morton_encode_u8_2d

Encodes an array of 2 u8 values ([u8; 2]), producing a u16 value as the result.

morton_encode_u8_3d

Encodes an array of 3 u8 values ([u8; 3]), producing a u32 value as the result.

morton_encode_u8_4d

Encodes an array of 4 u8 values ([u8; 4]), producing a u32 value as the result.

morton_encode_u8_5d

Encodes an array of 5 u8 values ([u8; 5]), producing a u64 value as the result.

morton_encode_u8_6d

Encodes an array of 6 u8 values ([u8; 6]), producing a u64 value as the result.

morton_encode_u8_7d

Encodes an array of 7 u8 values ([u8; 7]), producing a u64 value as the result.

morton_encode_u8_8d

Encodes an array of 8 u8 values ([u8; 8]), producing a u64 value as the result.

morton_encode_u8_9d

Encodes an array of 9 u8 values ([u8; 9]), producing a u128 value as the result.

morton_encode_u8_10d

Encodes an array of 10 u8 values ([u8; 10]), producing a u128 value as the result.

morton_encode_u8_11d

Encodes an array of 11 u8 values ([u8; 11]), producing a u128 value as the result.

morton_encode_u8_12d

Encodes an array of 12 u8 values ([u8; 12]), producing a u128 value as the result.

morton_encode_u8_13d

Encodes an array of 13 u8 values ([u8; 13]), producing a u128 value as the result.

morton_encode_u8_14d

Encodes an array of 14 u8 values ([u8; 14]), producing a u128 value as the result.

morton_encode_u8_15d

Encodes an array of 15 u8 values ([u8; 15]), producing a u128 value as the result.

morton_encode_u8_16d

Encodes an array of 16 u8 values ([u8; 16]), producing a u128 value as the result.

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 Option.

tobuint

A convenience function for converting primitive values to BigUints.