Skip to content

Commit 7f4c168

Browse files
committed
Rename the fields in SparseBitMatrix.
The new names are clearer.
1 parent d0d81b7 commit 7f4c168

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/librustc_data_structures/bitvec.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -326,23 +326,23 @@ where
326326
R: Idx,
327327
C: Idx,
328328
{
329-
columns: usize,
330-
vector: IndexVec<R, BitArray<C>>,
329+
num_columns: usize,
330+
rows: IndexVec<R, BitArray<C>>,
331331
}
332332

333333
impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
334334
/// Create a new empty sparse bit matrix with no rows or columns.
335-
pub fn new(columns: usize) -> Self {
335+
pub fn new(num_columns: usize) -> Self {
336336
Self {
337-
columns,
338-
vector: IndexVec::new(),
337+
num_columns,
338+
rows: IndexVec::new(),
339339
}
340340
}
341341

342342
fn ensure_row(&mut self, row: R) {
343-
let columns = self.columns;
344-
self.vector
345-
.ensure_contains_elem(row, || BitArray::new(columns));
343+
let num_columns = self.num_columns;
344+
self.rows
345+
.ensure_contains_elem(row, || BitArray::new(num_columns));
346346
}
347347

348348
/// Sets the cell at `(row, column)` to true. Put another way, insert
@@ -351,15 +351,15 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
351351
/// Returns true if this changed the matrix, and false otherwise.
352352
pub fn add(&mut self, row: R, column: C) -> bool {
353353
self.ensure_row(row);
354-
self.vector[row].insert(column)
354+
self.rows[row].insert(column)
355355
}
356356

357357
/// Do the bits from `row` contain `column`? Put another way, is
358358
/// the matrix cell at `(row, column)` true? Put yet another way,
359359
/// if the matrix represents (transitive) reachability, can
360360
/// `row` reach `column`?
361361
pub fn contains(&self, row: R, column: C) -> bool {
362-
self.vector.get(row).map_or(false, |r| r.contains(column))
362+
self.rows.get(row).map_or(false, |r| r.contains(column))
363363
}
364364

365365
/// Add the bits from row `read` to the bits from row `write`,
@@ -370,49 +370,49 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
370370
/// `write` can reach everything that `read` can (and
371371
/// potentially more).
372372
pub fn merge(&mut self, read: R, write: R) -> bool {
373-
if read == write || self.vector.get(read).is_none() {
373+
if read == write || self.rows.get(read).is_none() {
374374
return false;
375375
}
376376

377377
self.ensure_row(write);
378-
let (bitvec_read, bitvec_write) = self.vector.pick2_mut(read, write);
378+
let (bitvec_read, bitvec_write) = self.rows.pick2_mut(read, write);
379379
bitvec_write.merge(bitvec_read)
380380
}
381381

382382
/// Merge a row, `from`, into the `into` row.
383383
pub fn merge_into(&mut self, into: R, from: &BitArray<C>) -> bool {
384384
self.ensure_row(into);
385-
self.vector[into].merge(from)
385+
self.rows[into].merge(from)
386386
}
387387

388388
/// Add all bits to the given row.
389389
pub fn add_all(&mut self, row: R) {
390390
self.ensure_row(row);
391-
self.vector[row].insert_all();
391+
self.rows[row].insert_all();
392392
}
393393

394394
/// Number of elements in the matrix.
395395
pub fn len(&self) -> usize {
396-
self.vector.len()
396+
self.rows.len()
397397
}
398398

399399
pub fn rows(&self) -> impl Iterator<Item = R> {
400-
self.vector.indices()
400+
self.rows.indices()
401401
}
402402

403403
/// Iterates through all the columns set to true in a given row of
404404
/// the matrix.
405405
pub fn iter<'a>(&'a self, row: R) -> impl Iterator<Item = C> + 'a {
406-
self.vector.get(row).into_iter().flat_map(|r| r.iter())
406+
self.rows.get(row).into_iter().flat_map(|r| r.iter())
407407
}
408408

409409
/// Iterates through each row and the accompanying bit set.
410410
pub fn iter_enumerated<'a>(&'a self) -> impl Iterator<Item = (R, &'a BitArray<C>)> + 'a {
411-
self.vector.iter_enumerated()
411+
self.rows.iter_enumerated()
412412
}
413413

414414
pub fn row(&self, row: R) -> Option<&BitArray<C>> {
415-
self.vector.get(row)
415+
self.rows.get(row)
416416
}
417417
}
418418

0 commit comments

Comments
 (0)