@@ -5,7 +5,7 @@ use crate::Point;
5
5
pub struct Grid {
6
6
width : usize ,
7
7
height : usize ,
8
- cells : Vec < bool > ,
8
+ nodes : Vec < bool > ,
9
9
}
10
10
11
11
impl Grid {
@@ -14,7 +14,7 @@ impl Grid {
14
14
Self {
15
15
width,
16
16
height,
17
- cells : vec ! [ false ; width * height] ,
17
+ nodes : vec ! [ false ; width * height] ,
18
18
}
19
19
}
20
20
@@ -24,16 +24,16 @@ impl Grid {
24
24
pub fn from_2d ( grid : Vec < Vec < bool > > ) -> Self {
25
25
let height = grid. len ( ) ;
26
26
let width = grid. first ( ) . map_or ( 0 , Vec :: len) ;
27
- let mut cells = Vec :: with_capacity ( width * height) ;
27
+ let mut nodes = Vec :: with_capacity ( width * height) ;
28
28
29
29
for row in grid {
30
- cells . extend ( row) ;
30
+ nodes . extend ( row) ;
31
31
}
32
32
33
33
Self {
34
34
width,
35
35
height,
36
- cells ,
36
+ nodes : nodes ,
37
37
}
38
38
}
39
39
@@ -49,7 +49,7 @@ impl Grid {
49
49
self . height
50
50
}
51
51
52
- /// Returns the index of the cell at (x, y) coordinates.
52
+ /// Returns the index of the node at (x, y) coordinates.
53
53
#[ inline]
54
54
#[ must_use]
55
55
pub fn index ( & self , x : isize , y : isize ) -> Option < usize > {
@@ -60,21 +60,21 @@ impl Grid {
60
60
}
61
61
}
62
62
63
- /// Returns the value of the cell at (x, y) coordinates.
63
+ /// Returns the value of the node at (x, y) coordinates.
64
64
#[ must_use]
65
65
pub fn get ( & self , x : isize , y : isize ) -> Option < bool > {
66
- self . index ( x, y) . map ( |i| self . cells [ i] )
66
+ self . index ( x, y) . map ( |i| self . nodes [ i] )
67
67
}
68
68
69
- /// Returns a mutable reference to the cell at (x, y) coordinates.
69
+ /// Returns a mutable reference to the node at (x, y) coordinates.
70
70
#[ must_use]
71
71
pub fn get_mut ( & mut self , x : isize , y : isize ) -> Option < & mut bool > {
72
- self . index ( x, y) . map ( |i| & mut self . cells [ i] )
72
+ self . index ( x, y) . map ( |i| & mut self . nodes [ i] )
73
73
}
74
74
75
- /// Returns whether the cell at a given `Point` is walkable.
75
+ /// Returns whether the node at a given `Point` is walkable.
76
76
#[ must_use]
77
77
pub fn is_walkable ( & self , point : Point ) -> bool {
78
- self . get ( point. x , point. y ) . map_or ( false , |cell | !cell )
78
+ self . get ( point. x , point. y ) . map_or ( false , |node | !node )
79
79
}
80
80
}
0 commit comments