Struct gol_core::neighbors::grid_surround::NeighborsGridSurround [−][src]
Implementations
impl<T> NeighborsGridSurround<T>
[src]
pub fn new(margin: T) -> Self where
T: Clone,
[src]
T: Clone,
Creates a new neighbor calculator with equal margin on all sides and dimensions.
use gol_core::{ NeighborsGridSurround, BoardNeighborManager, GridPoint2D, GridPoint3D }; // Create Conway's Game of Life margin: 1 on each side. let neighbor_calc = NeighborsGridSurround::new(1usize); let cur_point = GridPoint2D{ x: 10, y: 5 }; let neighbors: Vec<GridPoint2D<i32>> = neighbor_calc.get_neighbors_idx(&cur_point).collect(); assert_eq!(neighbors.len(), 8); let neighbor_calc_2 = NeighborsGridSurround::new(1usize); let cur_point = GridPoint3D{ x: 10, y: 5, z: 9}; let neighbors_2: Vec<GridPoint3D<i32>> = neighbor_calc_2.get_neighbors_idx(&cur_point).collect(); assert_eq!(neighbors_2.len(), 26);
pub fn new_with_variable_margin<'a, 'b, I>(margins: I) -> Self where
'a: 'b,
T: 'a + Clone,
I: Iterator<Item = &'b (T, T)>,
[src]
'a: 'b,
T: 'a + Clone,
I: Iterator<Item = &'b (T, T)>,
Creates a new neighbor calculator with specific margin on each side and dimension. Elements in the vector represents different dimensions, the two values inside the vector represents margin on the negative and positive side along that dimension.
use gol_core::{GridPoint2D, NeighborsGridSurround, BoardNeighborManager}; // Create 2D margin with 2 on all sides but positive y-axis. let margins = [(2usize, 2), (2usize, 1)]; let neighbor_calc = NeighborsGridSurround::new_with_variable_margin(margins.iter()); let cur_point = GridPoint2D{ x: 10, y: 5 }; let neighbors: Vec<GridPoint2D<i32>> = neighbor_calc.get_neighbors_idx(&cur_point).collect(); assert_eq!(neighbors.len(), 19);
Trait Implementations
impl<T, U> BoardNeighborManager<GridPoint1D<U>, IntoIter<GridPoint1D<U>, Global>> for NeighborsGridSurround<T> where
T: MarginPrimInt,
U: PointPrimInt + TryFrom<T>,
[src]
T: MarginPrimInt,
U: PointPrimInt + TryFrom<T>,
fn get_neighbors_idx(&self, idx: &GridPoint1D<U>) -> IntoIter<GridPoint1D<U>>
[src]
impl<T, U> BoardNeighborManager<GridPoint2D<U>, IntoIter<GridPoint2D<U>, Global>> for NeighborsGridSurround<T> where
T: MarginPrimInt,
U: PointPrimInt + TryFrom<T>,
[src]
T: MarginPrimInt,
U: PointPrimInt + TryFrom<T>,
fn get_neighbors_idx(&self, idx: &GridPoint2D<U>) -> IntoIter<GridPoint2D<U>>
[src]
impl<T, U> BoardNeighborManager<GridPoint3D<U>, IntoIter<GridPoint3D<U>, Global>> for NeighborsGridSurround<T> where
T: MarginPrimInt,
U: PointPrimInt + TryFrom<T>,
[src]
T: MarginPrimInt,
U: PointPrimInt + TryFrom<T>,
fn get_neighbors_idx(&self, idx: &GridPoint3D<U>) -> IntoIter<GridPoint3D<U>>
[src]
impl<T, U> BoardNeighborManager<GridPointND<U>, IntoIter<GridPointND<U>, Global>> for NeighborsGridSurround<T> where
T: MarginPrimInt,
U: PointPrimInt,
[src]
T: MarginPrimInt,
U: PointPrimInt,
fn get_neighbors_idx(&self, idx: &GridPointND<U>) -> IntoIter<GridPointND<U>>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for NeighborsGridSurround<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for NeighborsGridSurround<T> where
T: Send,
T: Send,
impl<T> Sync for NeighborsGridSurround<T> where
T: Sync,
T: Sync,
impl<T> Unpin for NeighborsGridSurround<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for NeighborsGridSurround<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,