Skip to content

Commit

Permalink
feat: retain & clear
Browse files Browse the repository at this point in the history
  • Loading branch information
JakkuSakura committed May 22, 2024
1 parent cf4f212 commit 14026bc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/worktable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,17 @@ impl WorkTable {
}
}
pub fn retain(&mut self, f: impl Fn(&RowViewMut) -> bool) {
self.iter_mut().filter(f).for_each(|row| {
// remove from reverse order is generally faster
self.iter_mut().rev().filter(|x| !f(x)).for_each(|row| {
row.remove();
});
}
pub fn clear(&mut self) {
self.column_values.iter_mut().for_each(|x| x.clear());
if let Some(primary_map) = &mut self.primary_map {
primary_map.clear();
}
}
}

pub type SyncWorkTable = Arc<RwLock<WorkTable>>;
Expand Down

0 comments on commit 14026bc

Please sign in to comment.