mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-22 13:14:40 +02:00
Added cleaning function.
This commit is contained in:
parent
abe8a4bb86
commit
3d4de7867c
@ -77,8 +77,19 @@ impl Default for DataCollection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DataCollection {
|
impl DataCollection {
|
||||||
pub fn clean_data(&mut self) {
|
pub fn clean_data(&mut self, max_time_millis: u128) {
|
||||||
// TODO: [OPT] To implement to clean
|
let current_time = Instant::now();
|
||||||
|
|
||||||
|
let mut remove_index = 0;
|
||||||
|
for entry in &self.timed_data_vec {
|
||||||
|
if current_time.duration_since(entry.0).as_millis() > max_time_millis {
|
||||||
|
remove_index += 1;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.timed_data_vec.drain(0..remove_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eat_data(&mut self, harvested_data: &Data) {
|
pub fn eat_data(&mut self, harvested_data: &Data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user