Struct aoc_grid::GridBuf

source ·
pub struct GridBuf<Storage, Pos, const DIMS: usize>where
    Pos: GridPos<DIMS>,{ /* private fields */ }
Expand description

Multi dimensional abstraction over a single dimensional collection

This allows a simple one-dimensional collection to be accessed in a multi-dimensional way. It wraps a backing collection which implements GridStorage, and takes indexes which implement GridPos.

Implementations§

source§

impl<Storage, Pos, const DIMS: usize> GridBuf<Storage, Pos, DIMS>where Storage: GridStorage + Clone, Pos: GridPos<DIMS>,

source

pub fn wrap_range(storage: Storage, start: Pos, end: Pos) -> NumResult<Self>

source

pub fn wrap_size(storage: Storage, size: Pos) -> Self

source§

impl<Storage, Pos, const DIMS: usize> GridBuf<Storage, Pos, DIMS>where Storage: GridStorage + Clone, Pos: GridPos<DIMS>,

source

pub fn new_range(start: Pos, end: Pos) -> NumResult<Self>where Storage: FromIterator<Storage::Item>, Storage::Item: Clone + Default,

source

pub fn new_size(size: Pos) -> Selfwhere Storage: FromIterator<Storage::Item>, Storage::Item: Clone + Default,

source§

impl<Storage, Pos, const DIMS: usize> GridBuf<Storage, Pos, DIMS>where Storage: GridStorage + Clone, Pos: GridPos<DIMS>,

source

pub fn set_index(&mut self, idx: usize, item: Storage::Item)

source

pub fn set(&mut self, pos: Pos, item: Storage::Item)

source

pub fn try_set(&mut self, pos: Pos, item: Storage::Item) -> Option<()>

source

pub fn translate(&self, offset: Pos) -> NumResult<Self>

source§

impl<Item, Pos, const DIMS: usize> GridBuf<Vec<Item>, Pos, DIMS>where Item: Default, Pos: GridPos<DIMS>,

source

pub fn reset(&mut self)

source§

impl<Storage, Pos, const DIMS: usize> GridBuf<Storage, Pos, DIMS>where Storage: GridStorageMut + Clone, Pos: GridPos<DIMS>,

source

pub fn get_ref(&self, pos: Pos) -> Option<&Storage::Item>

source

pub fn get_mut(&mut self, pos: Pos) -> Option<&mut Storage::Item>

source§

impl<Storage, Pos> GridBuf<Storage, Pos, 2>where Storage: GridStorage, Storage::Item: Display, Pos: GridPosDisplay,

source

pub fn display_with_delim<Delim: Display>( &self, delim: Delim, formatter: &mut Formatter<'_> ) -> Result

source§

impl<'inp, Storage, Pos> GridBuf<Storage, Pos, 2>where Pos: GridPosParse, Storage: Clone + FromIterator<Storage::Item> + GridStorage, Storage::Item: Clone + Default + FromParser<'inp>,

source

pub fn parse_with_delim_and_fn( parser: &mut Parser<'inp>, delim: impl ParseDelimiter, default_fn: impl Fn() -> Storage::Item, parse_fn: impl Fn(&mut Parser<'inp>) -> ParseResult<Storage::Item> + Clone ) -> ParseResult<Self>

source

pub fn parse_with_delim( parser: &mut Parser<'inp>, default_fn: impl Fn() -> Storage::Item, delim: impl ParseDelimiter ) -> ParseResult<Self>

source

pub fn parse_with_fn( parser: &mut Parser<'inp>, default_fn: impl Fn() -> Storage::Item, parse_fn: impl Fn(&mut Parser<'inp>) -> ParseResult<Storage::Item> + Clone ) -> ParseResult<Self>

source§

impl<'grd, Storage, Pos, const DIMS: usize> GridBuf<Storage, Pos, DIMS>where Storage: GridStorage + Clone + FromIterator<<Storage as GridStorage>::Item> + 'grd, Storage::Item: Default, &'grd Storage: GridStorageIntoIter, Pos: GridPos<DIMS>,

source

pub fn resize(&'grd self, start: Pos, end: Pos) -> NumResult<Self>where <Storage as GridStorage>::Item: Default,

source

pub fn extend_in_place( &'grd self, amts: [(Pos::Coord, Pos::Coord); DIMS] ) -> NumResult<Self>where <Storage as GridStorage>::Item: Default,

Trait Implementations§

source§

impl<Storage: Clone, Pos, const DIMS: usize> Clone for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS> + Clone,

source§

fn clone(&self) -> GridBuf<Storage, Pos, DIMS>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Storage, Pos, const DIMS: usize> Debug for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS>,

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Storage, Pos> Display for GridBuf<Storage, Pos, 2>where Storage: GridStorage, Storage::Item: Display, Pos: GridPosDisplay,

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'inp, Storage, Pos> FromParser<'inp> for GridBuf<Storage, Pos, 2>where Pos: GridPosParse, Storage: Clone + FromIterator<Storage::Item> + GridStorage, Storage::Item: Clone + Default + FromParser<'inp>,

source§

fn from_parser(parser: &mut Parser<'inp>) -> ParseResult<Self>

source§

fn parse_from_str(input: &'inp str) -> Result<Self, Box<dyn Error, Global>>

source§

fn parse_from_lines( input: &'inp [&'inp str] ) -> Result<Self, Box<dyn Error, Global>>

source§

impl<'grd, Storage, Pos, const DIMS: usize> GridView<Pos, DIMS> for &'grd GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS>, Storage: GridStorage,

§

type Item = <Storage as GridStorage>::Item

§

type Cursors = GridCursorIter<Pos, DIMS>

source§

fn start(self) -> Pos

source§

fn end(self) -> Pos

source§

fn size(self) -> Pos

source§

fn get_trusted(self, _native: Pos, idx: usize) -> Storage::Item

source§

fn cursors(self) -> GridCursorIter<Pos, DIMS>

source§

fn len(self) -> usize

source§

fn is_empty(self) -> bool

source§

fn keys(self) -> GridKeysIter<Pos, DIMS>

source§

fn first_key(self) -> Pos

source§

fn last_key(self) -> Pos

source§

fn get(self, pos: Pos) -> Option<Self::Item>

source§

fn get_native(self, native: Pos) -> Option<Self::Item>

source§

fn offset(self, pos: Pos) -> NumResult<GridOffset<Pos, DIMS>>

source§

fn cursor(self, pos: Pos) -> Option<GridCursor<Pos, DIMS>>

source§

fn map<Storage, MapFn, Output>( self, map_fn: MapFn ) -> GridBuf<Storage, Pos, DIMS>where MapFn: FnMut(GridCursor<Pos, DIMS>) -> Output, Storage: Clone + GridStorage + FromIterator<Output>,

source§

fn try_map<Storage, MapFn, Output, Error>( self, map_fn: MapFn ) -> Result<GridBuf<Storage, Pos, DIMS>, Error>where MapFn: FnMut(GridCursor<Pos, DIMS>) -> Result<Output, Error>, Storage: Clone + GridStorage + FromIterator<Output>,

source§

impl<'grd, Storage, Pos, const DIMS: usize> GridViewIter<Pos, DIMS> for &'grd GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS>, Storage: GridStorage, &'grd Storage: GridStorageIntoIter<Item = Self::Item>,

§

type Values = <&'grd Storage as GridStorageIntoIter>::Iter

source§

fn values(self) -> Self::Values

source§

fn iter(self) -> GridIter<Self::Values, Pos, DIMS>where Self: Copy + Sized,

source§

fn to_buf<Storage>(self) -> GridBuf<Storage, Pos, DIMS>where Storage: Clone + GridStorage + FromIterator<Self::Item>,

source§

impl<Storage: Hash, Pos, const DIMS: usize> Hash for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS> + Hash,

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<Storage: Ord, Pos, const DIMS: usize> Ord for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS> + Ord,

source§

fn cmp(&self, other: &GridBuf<Storage, Pos, DIMS>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<Storage: PartialEq, Pos, const DIMS: usize> PartialEq<GridBuf<Storage, Pos, DIMS>> for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS> + PartialEq,

source§

fn eq(&self, other: &GridBuf<Storage, Pos, DIMS>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Storage: PartialOrd, Pos, const DIMS: usize> PartialOrd<GridBuf<Storage, Pos, DIMS>> for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS> + PartialOrd,

source§

fn partial_cmp(&self, other: &GridBuf<Storage, Pos, DIMS>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<Storage: Eq, Pos, const DIMS: usize> Eq for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS> + Eq,

source§

impl<Storage, Pos, const DIMS: usize> StructuralEq for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS>,

source§

impl<Storage, Pos, const DIMS: usize> StructuralPartialEq for GridBuf<Storage, Pos, DIMS>where Pos: GridPos<DIMS>,

Auto Trait Implementations§

§

impl<Storage, Pos, const DIMS: usize> RefUnwindSafe for GridBuf<Storage, Pos, DIMS>where Pos: RefUnwindSafe, Storage: RefUnwindSafe,

§

impl<Storage, Pos, const DIMS: usize> Send for GridBuf<Storage, Pos, DIMS>where Pos: Send, Storage: Send,

§

impl<Storage, Pos, const DIMS: usize> Sync for GridBuf<Storage, Pos, DIMS>where Pos: Sync, Storage: Sync,

§

impl<Storage, Pos, const DIMS: usize> Unpin for GridBuf<Storage, Pos, DIMS>where Pos: Unpin, Storage: Unpin,

§

impl<Storage, Pos, const DIMS: usize> UnwindSafe for GridBuf<Storage, Pos, DIMS>where Pos: UnwindSafe, Storage: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<From, To> QuickInto<To> for Fromwhere To: QuickFrom<From>,

source§

fn quick_into(self) -> To

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.