You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/artificialintelligence/assignments/maze/maze-datastructure.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,7 @@ struct RoomRegistry {
175
175
};
176
176
```
177
177
178
-
Before going deep into how can we address the indexes for the walls, you need to know vector<bool> are not common vectors where each element returns a reference to a bool. Instead, it returns a proxy object that behaves like a bool. This is because the standard vector<bool> is a specialization of the vector class that is optimized for space efficiency.
178
+
Before going deep into how can we address the indexes for the walls, you need to know `vector<bool>` are not common vectors where each element returns a reference to a bool. Instead, it returns a proxy object that behaves like a bool. This is because the standard `vector<bool>` is a specialization of the vector class that is optimized for space efficiency.
179
179
180
180
```c++
181
181
// Example of how vector<bool> works
@@ -191,7 +191,7 @@ stuct vector<bool> {
191
191
192
192

193
193
194
-
Now we have a way to address bits directly using vector<bool>, but you need to remember that for an X x Y grid, we will need X+1 vertical walls and Y+1 horizontal walls. Check the following example below for a 2x2 grid:
194
+
Now we have a way to address bits directly using `vector<bool>`, but you need to remember that for an X x Y grid, we will need X+1 vertical walls and Y+1 horizontal walls. Check the following example below for a 2x2 grid:
195
195
196
196
```
197
197
_ _
@@ -201,7 +201,7 @@ Now we have a way to address bits directly using vector<bool>, but you need to r
201
201
202
202
So we will need 3 vertical walls and 3 horizontal walls.
203
203
204
-
Now, we reached to the next issue. How can we address the walls in the std::vector<bool>? We will need to change our point of view from addressing Rooms at position (X,Y) to WallIntersections. Every intersection will be 2 bits to represent vertical and horizontal walls.
204
+
Now, we reached to the next issue. How can we address the walls in the `std::vector<bool>`? We will need to change our point of view from addressing Rooms at position (X,Y) to WallIntersections. Every intersection will be 2 bits to represent vertical and horizontal walls.
205
205
206
206
```
207
207
_ _
@@ -277,4 +277,4 @@ struct RoomRegistry {
277
277
278
278
## Conclusion
279
279
280
-
Now we are using the most memory efficient way to represent a dense maze. We learned matrix flattening, bit index addressing, data layout, and discovered why vector<bool> is a bit different from other vectors.
280
+
Now we are using the most memory efficient way to represent a dense maze. We learned matrix flattening, bit index addressing, data layout, and discovered why `vector<bool>` is a bit different from other vectors.
0 commit comments