Remove scheme by ID

This commit is contained in:
Jeremy Soller
2019-07-18 20:57:51 -06:00
parent 5af7f71a99
commit 4b2c15f0b9

View File

@@ -9,6 +9,7 @@
use alloc::sync::Arc;
use alloc::boxed::Box;
use alloc::collections::BTreeMap;
use alloc::vec::Vec;
use core::sync::atomic::AtomicUsize;
use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard};
@@ -234,6 +235,22 @@ impl SchemeList {
}
Ok(id)
}
/// Remove a scheme
pub fn remove(&mut self, id: SchemeId) {
assert!(self.map.remove(&id).is_some());
for (_ns, names) in self.names.iter_mut() {
let mut remove = Vec::with_capacity(1);
for (name, name_id) in names.iter() {
if name_id == &id {
remove.push(name.clone());
}
}
for name in remove {
assert!(names.remove(&name).is_some());
}
}
}
}
/// Schemes list