mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
cleanup
This commit is contained in:
parent
c5f433ab94
commit
0aa7cb8479
2 changed files with 2 additions and 150 deletions
|
@ -36,40 +36,10 @@ impl ReferenceMatrix {
|
|||
self.bitvec.set(row * self.length + col, value)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get(&self, index: usize) -> bool {
|
||||
self.bitvec[index]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_row_col(&self, row: usize, col: usize) -> bool {
|
||||
self.bitvec[row * self.length + col]
|
||||
}
|
||||
|
||||
pub fn is_recursive(&self, index: usize) -> bool {
|
||||
let mut scheduled = self.row_slice(index).to_bitvec();
|
||||
let mut visited = self.row_slice(index).to_bitvec();
|
||||
|
||||
// yes this is a bit inefficient because rows are visited repeatedly.
|
||||
while scheduled.any() {
|
||||
for one in scheduled.iter_ones() {
|
||||
if one == index {
|
||||
return true;
|
||||
}
|
||||
|
||||
visited |= self.row_slice(one)
|
||||
}
|
||||
|
||||
// i.e. visited did not change
|
||||
if visited.count_ones() == scheduled.count_ones() {
|
||||
break;
|
||||
}
|
||||
|
||||
scheduled |= &visited;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// Topological sort and strongly-connected components
|
||||
|
@ -81,6 +51,7 @@ impl ReferenceMatrix {
|
|||
//
|
||||
// Thank you, Samuel!
|
||||
impl ReferenceMatrix {
|
||||
#[allow(dead_code)]
|
||||
pub fn topological_sort_into_groups(&self) -> TopologicalSort {
|
||||
if self.length == 0 {
|
||||
return TopologicalSort::Groups { groups: Vec::new() };
|
||||
|
@ -178,6 +149,7 @@ impl ReferenceMatrix {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum TopologicalSort {
|
||||
/// There were no cycles, all nodes have been partitioned into groups
|
||||
Groups { groups: Vec<Vec<u32>> },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue