mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
use ReferenceMatrix in DefOrdering
This commit is contained in:
parent
0c10fa31f5
commit
9f7c7b56a1
2 changed files with 23 additions and 233 deletions
|
@ -3,6 +3,7 @@ pub(crate) type Element = u8;
|
|||
pub(crate) type BitVec = bitvec::vec::BitVec<Element>;
|
||||
pub(crate) type BitSlice = bitvec::prelude::BitSlice<Element>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct ReferenceMatrix {
|
||||
bitvec: BitVec,
|
||||
length: usize,
|
||||
|
@ -25,26 +26,19 @@ impl ReferenceMatrix {
|
|||
&self.bitvec[row * self.length..][..self.length]
|
||||
}
|
||||
|
||||
pub const fn len(&self) -> usize {
|
||||
self.length
|
||||
}
|
||||
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
self.length == 0
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn set(&mut self, index: usize, value: bool) {
|
||||
pub fn set(&mut self, index: usize, value: bool) {
|
||||
self.bitvec.set(index, value)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get(&self, index: usize) -> bool {
|
||||
pub fn get(&self, index: usize) -> bool {
|
||||
self.bitvec[index]
|
||||
}
|
||||
}
|
||||
|
||||
impl ReferenceMatrix {
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn topological_sort_into_groups(&self) -> Result<Vec<Vec<u32>>, (Vec<Vec<u32>>, Vec<u32>)> {
|
||||
let length = self.length;
|
||||
let bitvec = &self.bitvec;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue