pub struct Line1D { /* private fields */ }Expand description
A one-dimensional line lattice.
Each cell has coordinate [i] where 0 <= i < len.
Boundary handling is controlled by EdgeBehavior:
- Absorb: edge cells have fewer neighbors
- Clamp: edge cells self-loop
- Wrap: periodic boundary (equivalent to
Ring1D)
§Examples
use murk_space::{Line1D, EdgeBehavior, Space};
let line = Line1D::new(5, EdgeBehavior::Absorb).unwrap();
assert_eq!(line.len(), 5);
assert_eq!(line.cell_count(), 5);
assert_eq!(line.ndim(), 1);
// Interior cell has two neighbours.
let coord: murk_core::Coord = vec![2i32].into();
assert_eq!(line.neighbours(&coord).len(), 2);
// Edge cell (absorb) has only one neighbour.
let edge: murk_core::Coord = vec![0i32].into();
assert_eq!(line.neighbours(&edge).len(), 1);Implementations§
Source§impl Line1D
impl Line1D
Sourcepub fn new(len: u32, edge: EdgeBehavior) -> Result<Self, SpaceError>
pub fn new(len: u32, edge: EdgeBehavior) -> Result<Self, SpaceError>
Create a new 1D line with len cells and the given edge behavior.
Returns Err(SpaceError::EmptySpace) if len == 0, or
Err(SpaceError::DimensionTooLarge) if len > i32::MAX.
Sourcepub fn edge_behavior(&self) -> EdgeBehavior
pub fn edge_behavior(&self) -> EdgeBehavior
Edge behavior.
Trait Implementations§
Source§impl Space for Line1D
impl Space for Line1D
Source§fn cell_count(&self) -> usize
fn cell_count(&self) -> usize
Total number of cells in the space.
Source§fn neighbours(&self, coord: &Coord) -> SmallVec<[Coord; 8]>
fn neighbours(&self, coord: &Coord) -> SmallVec<[Coord; 8]>
Enumerate the neighbors of a cell. Read more
Source§fn max_neighbour_degree(&self) -> usize
fn max_neighbour_degree(&self) -> usize
Maximum neighbor-list length over all cells in this space. Read more
Source§fn compile_region(&self, spec: &RegionSpec) -> Result<RegionPlan, SpaceError>
fn compile_region(&self, spec: &RegionSpec) -> Result<RegionPlan, SpaceError>
Compile a region specification into a plan for O(1) lookups.
Source§fn canonical_ordering(&self) -> Vec<Coord> ⓘ
fn canonical_ordering(&self) -> Vec<Coord> ⓘ
All cells in deterministic canonical order. Read more
Source§fn canonical_rank(&self, coord: &Coord) -> Option<usize>
fn canonical_rank(&self, coord: &Coord) -> Option<usize>
Position of a coordinate in the canonical ordering. Read more
Source§fn canonical_rank_slice(&self, coord: &[i32]) -> Option<usize>
fn canonical_rank_slice(&self, coord: &[i32]) -> Option<usize>
Position of a coordinate slice in the canonical ordering. Read more
Source§fn instance_id(&self) -> SpaceInstanceId
fn instance_id(&self) -> SpaceInstanceId
Unique instance identifier for this space object. Read more
Source§fn topology_eq(&self, other: &dyn Space) -> bool
fn topology_eq(&self, other: &dyn Space) -> bool
Returns
true if self and other are topologically equivalent:
same concrete type and identical behavioral parameters. Read moreSource§fn iter_region<'a>(
&'a self,
plan: &'a RegionPlan,
) -> Box<dyn Iterator<Item = Coord> + 'a>
fn iter_region<'a>( &'a self, plan: &'a RegionPlan, ) -> Box<dyn Iterator<Item = Coord> + 'a>
Iterate over the cells in a compiled region. Read more
Source§fn map_coord_to_tensor_index(
&self,
coord: &Coord,
plan: &RegionPlan,
) -> Option<usize>
fn map_coord_to_tensor_index( &self, coord: &Coord, plan: &RegionPlan, ) -> Option<usize>
Map a coordinate to its flat tensor index within a compiled region. Read more
Auto Trait Implementations§
impl Freeze for Line1D
impl RefUnwindSafe for Line1D
impl Send for Line1D
impl Sync for Line1D
impl Unpin for Line1D
impl UnsafeUnpin for Line1D
impl UnwindSafe for Line1D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more