Add VecSet::insert_all

This commit is contained in:
Richard Feldman 2022-05-05 16:18:38 -04:00
parent e6a72578c1
commit 59023d2a88
No known key found for this signature in database
GPG Key ID: 7E4127D1E4241798

View File

@ -40,6 +40,17 @@ impl<T: PartialEq> VecSet<T> {
}
}
/// Returns true iff any of the given elements previoously existed in the set.
pub fn insert_all<I: Iterator<Item = T>>(&mut self, values: I) -> bool {
let mut any_existed = false;
for value in values {
any_existed = any_existed || self.insert(value);
}
any_existed
}
pub fn contains(&self, value: &T) -> bool {
self.elements.contains(value)
}