summaryrefslogtreecommitdiffstats
path: root/src/grid.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-12-13 00:57:17 -0500
committerJesse Luehrs <doy@tozt.net>2023-12-13 00:57:17 -0500
commit94d4fc2fc3a181bd79f92eb6d93c833e88e6e802 (patch)
tree89b0f147bfb7f288953d36189de8f677db2b6300 /src/grid.rs
parent747edc0066c138718c86ed7cdb9d1685b2ca81a7 (diff)
downloadadvent-of-code-94d4fc2fc3a181bd79f92eb6d93c833e88e6e802.tar.gz
advent-of-code-94d4fc2fc3a181bd79f92eb6d93c833e88e6e802.zip
day 13
Diffstat (limited to 'src/grid.rs')
-rw-r--r--src/grid.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/grid.rs b/src/grid.rs
index f299bee..b006882 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -269,6 +269,10 @@ impl<T: Clone + Eq + PartialEq + std::hash::Hash> Grid<T> {
(0..self.rows().0).map(Row)
}
+ pub fn row_vec(&self, row: Row) -> Vec<T> {
+ self.rows[row.0].cells.clone()
+ }
+
pub fn cols(&self) -> Col {
Col(self.rows[0].cells.len())
}
@@ -280,6 +284,10 @@ impl<T: Clone + Eq + PartialEq + std::hash::Hash> Grid<T> {
(0..self.cols().0).map(Col)
}
+ pub fn col_vec(&self, col: Col) -> Vec<T> {
+ self.rows.iter().map(|row| row[col].clone()).collect()
+ }
+
pub fn get(&self, row: Row) -> Option<&GridRow<T>> {
self.rows.get(row.0)
}