Coordinates

Trait Coordinates 

Source
trait Coordinates {
    // Required methods
    fn set_coord(&mut self, depth: usize, value: i32);
    fn truncate_to(&mut self, depth: usize);
    fn get(&self) -> Self;
}
Expand description

Trait for managing coordinates during iteration.

The iterator accumulates coordinates dimension-by-dimension as it descends. When it backtracks, it calls truncate_to to discard coordinates from deeper dimensions. When it yields an entry, it calls get to snapshot the current coordinates.

Required Methods§

Source

fn set_coord(&mut self, depth: usize, value: i32)

Sets the coordinate at the given depth (dimension index) to value.

Source

fn truncate_to(&mut self, depth: usize)

Discards any coordinate data beyond depth, preparing for backtracking.

Source

fn get(&self) -> Self

Returns a snapshot of the current coordinates.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<const K: usize> Coordinates for [i32; K]

Fixed-size coordinate accumulator for MultiIndexed.

truncate_to is a no-op since all dimensions are always present in the array; stale values at deeper indices are simply overwritten by set_coord before they are ever read.

Source§

fn set_coord(&mut self, depth: usize, value: i32)

Source§

fn truncate_to(&mut self, _depth: usize)

Source§

fn get(&self) -> Self

Implementors§

Source§

impl Coordinates for Vec<i32>

Dynamic coordinate accumulator for KdTrie.

set_coord pushes a new coordinate (asserting that depth == len, i.e. coordinates are always built in order), and truncate_to pops coordinates back to the given depth.