zorder
Crate provides functions to convert 2D coordinates to Z-order curve indexes and back. Z-order curve, also known as Morton code, is a mapping of 2D coordinates to 1D index which preverses locality. It is cache-efficient way of storing 2D data in 1D array.
Software implementation:
```rust use zorder::{indexof, coordof};
let idx = indexof((1, 1)); asserteq!(idx, 3);
let coord = coordof(idx); asserteq!(coord, (1, 1)); ```
In most cases faster bmi2
based implementation is also available:
```rust
{ use zorder::bmi2::{indexof, coordof};
if is_x86_feature_detected!("bmi2") {
let idx = unsafe { index_of((1, 1)) };
assert_eq!(idx, 3);
let coord = unsafe { coord_of(idx) };
assert_eq!(coord, (1, 1));
}
} ```
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.