[][src]Function moore_hilbert::coordinates_increment

pub fn coordinates_increment(
    bits_per_dimension: BitsPerDimensionType,
    coord: &mut [HilbertCoordinate]
)

Advance from one point to its successor on a Hilbert curve

Arguments

  • bits_per_dimension - Number of bits/coordinate.
  • coord - Coordinates that will be modified to be the next point on the curve

Assumptions

bits_per_dimension <= (sizeof HilbertIndex) * (bits_per_byte)

Example

let bits_per_dimension = 8;
let mut coords = vec![2, 2, 5];

/// Get the initial position along the Hilbert curve
let first_index = moore_hilbert::coordinates_to_index(bits_per_dimension, &coords).unwrap();

/// Increment that position
moore_hilbert::coordinates_increment(bits_per_dimension, &mut coords);

/// Convert the incremented position back to a new index on the Hilbert curve
let new_index = moore_hilbert::coordinates_to_index(bits_per_dimension, &coords).unwrap();

/// The newly incremented index should advance along the curve by 1.
assert_eq!(new_index-first_index, 1);