#[inline]
pub fn contains(&self, elem: T) -> bool {
let (word_index, mask) = word_index_and_mask(elem);
- if let Some(word) = self.bit_set.words.get(word_index) { (word & mask) != 0 } else { false }
+ self.bit_set.words.get(word_index).map_or(false, |word| (word & mask) != 0)
}
}
pub fn insert_all_into_row(&mut self, row: R) {
assert!(row.index() < self.num_rows);
let (start, end) = self.range(row);
- let words = &mut self.words[..];
- for index in start..end {
- words[index] = !0;
+ for word in self.words[start..end].iter_mut() {
+ *word = !0;
}
self.clear_excess_bits(row);
}
}
fn ensure_row(&mut self, row: R) -> &mut HybridBitSet<C> {
- // Instantiate any missing rows up to and including row `row` with an
- // empty HybridBitSet.
- self.rows.ensure_contains_elem(row, || None);
-
+ // Instantiate any missing rows up to and including row `row` with an empty HybridBitSet.
// Then replace row `row` with a full HybridBitSet if necessary.
- let num_columns = self.num_columns;
- self.rows[row].get_or_insert_with(|| HybridBitSet::new_empty(num_columns))
+ self.rows.get_or_insert_with(row, || HybridBitSet::new_empty(self.num_columns))
}
/// Sets the cell at `(row, column)` to true. Put another way, insert
/// Iterates through all the columns set to true in a given row of
/// the matrix.
- pub fn iter<'a>(&'a self, row: R) -> impl Iterator<Item = C> + 'a {
+ pub fn iter(&self, row: R) -> impl Iterator<Item = C> + '_ {
self.row(row).into_iter().flat_map(|r| r.iter())
}