Struct ArrayGrid2

Source
pub struct ArrayGrid2<T> { /* private fields */ }
Expand description

Heap-allocated array implementation of Grid2.

Implementations§

Source§

impl<T> ArrayGrid2<T>

Source

pub fn new<I, F>(x_len: i32, y_len: i32, startval: F) -> Self
where I: From<Vector2<i32>>, F: FnMut(I) -> T,

Source

pub fn broadcast(x_len: i32, y_len: i32, startval: T) -> Self
where T: Clone,

Trait Implementations§

Source§

impl<T> Grid2 for ArrayGrid2<T>

Source§

type Item = T

Source§

type XBound = Range0To

Source§

type YBound = Range0To

Source§

fn x_bound(&self) -> Range0To

Source§

fn y_bound(&self) -> Range0To

Source§

fn in_bounds<I>(&self, coord: I) -> bool
where I: Into<Vector2<i32>>,

Source§

fn map<F, T>(self, func: F) -> Grid2Map<Self, F, T>
where Self: Sized, F: Fn(Self::Item) -> T,

Element by-value mapping.
Source§

fn enumap<I, F, T>(self, func: F) -> Grid2EnuMap<Self, F, T, I>
where Self: Sized, I: From<Vector2<i32>>, F: Fn(I, Self::Item) -> T,

Element by-value+coord mapping.
Source§

fn flatten<I>(self, stride: I) -> Grid2Flat<Self>
where Self: Sized, Self::Item: Grid2, Self::XBound: Clone + RangeBoundsTimes, Self::YBound: Clone + RangeBoundsTimes, I: Into<Vector2<i32>>,

Flattening a grid of grids with a regular stride.
Source§

fn new_origin<I>(self, new_origin: I) -> Grid2NewOrigin<Self>
where Self: Sized, Self::XBound: RangeBoundsPlus, Self::YBound: RangeBoundsPlus, I: Into<Vector2<i32>>,

<0, 0> in this grid becomes new_origin in resultant grid.
Source§

fn oob_handler<I, F>(self, handler: F) -> Grid2OobHandler<Self, I, F>
where Self: Sized, I: From<Vector2<i32>>, F: Fn(I) -> Self::Item,

Provide function to provide elments at out-of-bounds coordinates. Read more
Source§

fn subview<X, Y>(self, new_x: X, new_y: Y) -> Grid2Slice<Self, X, Y>
where Self: Sized, Self::XBound: Debug, Self::YBound: Debug, X: RangeBounds<i32> + Clone + Debug, Y: RangeBounds<i32> + Clone + Debug,

View a sub-rectangle of this grid. Read more
Source§

fn try_subview<X, Y>( self, new_x: X, new_y: Y, ) -> Result<Grid2Slice<Self, X, Y>, Self>
where Self: Sized, Self::XBound: Debug, Self::YBound: Debug, X: RangeBounds<i32> + Clone + Debug, Y: RangeBounds<i32> + Clone + Debug,

View a sub-rectangle of this grid. Read more
Source§

fn subview_0to( self, new_x_len: i32, new_y_len: i32, ) -> Grid2Slice<Self, Range0To, Range0To>
where Self: Sized, Self::XBound: Debug, Self::YBound: Debug,

View a sub-rectangle of this grid, beginning at origin. Read more
Source§

fn try_subview_0to( self, new_x_len: i32, new_y_len: i32, ) -> Result<Grid2Slice<Self, Range0To, Range0To>, Self>
where Self: Sized, Self::XBound: Debug, Self::YBound: Debug,

View a sub-rectangle of this grid, beginning at origin. Read more
Source§

fn wrapping(self) -> Grid2Wrapping<Self>
where Self: Sized, Self::XBound: BoundRange, Self::YBound: BoundRange,

View of this grid which wraps around the edges. Read more
Source§

fn collect(&self) -> ArrayGrid2<Self::Item>
where Self: Grid2Get, Self::XBound: Into<Range0To>, Self::YBound: Into<Range0To>,

Collect a grid’s elements into a heap allocation. Read more
Source§

impl<T: Clone> Grid2Get for ArrayGrid2<T>

Source§

fn get<I: Into<Vector2<i32>>>(&self, coord: I) -> Self::Item

Source§

fn try_get<I>(&self, coord: I) -> Option<Self::Item>
where I: Into<Vector2<i32>>,

Source§

impl<T> Grid2Len for ArrayGrid2<T>

Source§

fn x_len(&self) -> i32

Source§

fn y_len(&self) -> i32

Source§

impl<T> Grid2Mut for ArrayGrid2<T>

Source§

fn midx<I>(&mut self, coord: I) -> &mut Self::Item
where I: Into<Vector2<i32>>,

Source§

fn try_midx<I>(&mut self, coord: I) -> Option<&mut Self::Item>
where I: Into<Vector2<i32>>,

Source§

impl<T> Grid2Ref for ArrayGrid2<T>

Source§

fn idx<I>(&self, coord: I) -> &Self::Item
where I: Into<Vector2<i32>>,

Source§

fn try_idx<I>(&self, coord: I) -> Option<&Self::Item>
where I: Into<Vector2<i32>>,

Source§

impl<T> Grid2Set for ArrayGrid2<T>

Source§

fn set<I: Into<Vector2<i32>>>(&mut self, coord: I, elem: Self::Item)

Source§

fn try_set<I>(&mut self, coord: I, elem: Self::Item) -> Result<(), Self::Item>
where I: Into<Vector2<i32>>,

Auto Trait Implementations§

§

impl<T> Freeze for ArrayGrid2<T>

§

impl<T> RefUnwindSafe for ArrayGrid2<T>
where T: RefUnwindSafe,

§

impl<T> Send for ArrayGrid2<T>
where T: Send,

§

impl<T> Sync for ArrayGrid2<T>
where T: Sync,

§

impl<T> Unpin for ArrayGrid2<T>

§

impl<T> UnwindSafe for ArrayGrid2<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.