Skip to content

Commit

Permalink
feat: add get_rows
Browse files Browse the repository at this point in the history
  • Loading branch information
JakkuSakura committed May 6, 2024
1 parent 121d52c commit b3eecc7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/worktable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum Value {
impl Eq for Value {}

impl PartialOrd for Value {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
Expand Down Expand Up @@ -346,14 +346,14 @@ impl WorkTable {
.collect(),
)
}
pub fn find_row_index(&self, mut check: impl FnMut(&RowView) -> bool) -> Option<usize> {
pub fn find_row_index(&self, mut check: impl FnMut(RowView) -> bool) -> Option<usize> {
for i in 0..self.shape().0 {
let row = RowView {
index: i,
column_names: &self.columns,
columns: &self.column_values,
};
if check(&row) {
if check(row) {
return Some(i);
}
}
Expand Down Expand Up @@ -451,6 +451,18 @@ impl WorkTable {
*col = new_columns;
}
}
pub fn get_rows(&self) -> impl Iterator<Item = RowView> {
let len = self.shape().0;
(0..len)
.map(|index| {
RowView {
index,
column_names: &self.columns,
columns: &self.column_values,
}
})

}
}
pub type SyncWorkTable = Arc<RwLock<WorkTable>>;

Expand Down

0 comments on commit b3eecc7

Please sign in to comment.