pub struct GridGraph<A> {
pub height: usize,
pub width: usize,
_marker: PhantomData<fn() -> A>,
}Fields§
§height: usize§width: usize§_marker: PhantomData<fn() -> A>Implementations§
Source§impl<A> GridGraph<A>
impl<A> GridGraph<A>
Sourcepub fn new(height: usize, width: usize) -> Self
pub fn new(height: usize, width: usize) -> Self
Examples found in repository?
crates/competitive/src/graph/grid.rs (line 13)
12 pub fn new_adj4(height: usize, width: usize) -> Self {
13 Self::new(height, width)
14 }
15 pub fn adj4(&self, vid: (usize, usize)) -> GridAdjacency<'_, Adj4> {
16 GridAdjacency {
17 g: self,
18 xy: vid,
19 diter: GridDirectionIter::default(),
20 _marker: PhantomData,
21 }
22 }
23}
24impl GridGraph<Adj8> {
25 pub fn new_adj8(height: usize, width: usize) -> Self {
26 Self::new(height, width)
27 }Sourcepub fn move_by_diff(
&self,
xy: (usize, usize),
dxdy: (isize, isize),
) -> Option<(usize, usize)>
pub fn move_by_diff( &self, xy: (usize, usize), dxdy: (isize, isize), ) -> Option<(usize, usize)>
pub fn flat(&self, xy: (usize, usize)) -> usize
pub fn unflat(&self, pos: usize) -> (usize, usize)
Trait Implementations§
impl<A: Copy> Copy for GridGraph<A>
Source§impl<A> Graph for GridGraph<A>
impl<A> Graph for GridGraph<A>
type Vertex = (usize, usize)
type Label = GridDirection
type Vertices<'g> = GridVertices where A: 'g
type Neighbors<'g> = Map<GridAdjacency<'g, A>, fn(((usize, usize), GridDirection)) -> Neighbor<(usize, usize), GridDirection>> where A: 'g
fn vsize(&self) -> usize
fn vertices(&self) -> Self::Vertices<'_>
fn neighbors(&self, vertex: Self::Vertex) -> Self::Neighbors<'_>
Source§impl<A, T> VertexMap<T> for GridGraph<A>
impl<A, T> VertexMap<T> for GridGraph<A>
type Vmap = Vec<T>
fn construct_vmap<F>(&self, f: F) -> Self::Vmapwhere
F: FnMut() -> T,
fn vmap_get<'a>(&self, map: &'a Self::Vmap, (x, y): Self::Vertex) -> &'a T
fn vmap_get_mut<'a>( &self, map: &'a mut Self::Vmap, (x, y): Self::Vertex, ) -> &'a mut T
fn vmap_set(&self, map: &mut Self::Vmap, vertex: Self::Vertex, value: T)
Auto Trait Implementations§
impl<A> Freeze for GridGraph<A>
impl<A> RefUnwindSafe for GridGraph<A>
impl<A> Send for GridGraph<A>
impl<A> Sync for GridGraph<A>
impl<A> Unpin for GridGraph<A>
impl<A> UnsafeUnpin for GridGraph<A>
impl<A> UnwindSafe for GridGraph<A>
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