rename BitSet to DenseBitSet

This should make it clearer that this bitset is dense, with the
advantages and disadvantages that it entails.
This commit is contained in:
Rémy Rakic
2025-01-07 15:19:05 +00:00
parent 7e4077d06f
commit a13354bea0
67 changed files with 367 additions and 356 deletions

View File

@@ -22,7 +22,7 @@
use std::fmt::Debug;
use rustc_index::bit_set::BitSet;
use rustc_index::bit_set::DenseBitSet;
use tracing::debug;
#[cfg(test)]
@@ -214,7 +214,7 @@ impl<N: Debug, E: Debug> Graph<N, E> {
direction: Direction,
entry_node: NodeIndex,
) -> Vec<NodeIndex> {
let mut visited = BitSet::new_empty(self.len_nodes());
let mut visited = DenseBitSet::new_empty(self.len_nodes());
let mut stack = vec![];
let mut result = Vec::with_capacity(self.len_nodes());
let mut push_node = |stack: &mut Vec<_>, node: NodeIndex| {
@@ -287,7 +287,7 @@ impl<'g, N: Debug, E: Debug> Iterator for AdjacentEdges<'g, N, E> {
pub struct DepthFirstTraversal<'g, N, E> {
graph: &'g Graph<N, E>,
stack: Vec<NodeIndex>,
visited: BitSet<usize>,
visited: DenseBitSet<usize>,
direction: Direction,
}
@@ -297,7 +297,7 @@ impl<'g, N: Debug, E: Debug> DepthFirstTraversal<'g, N, E> {
start_node: NodeIndex,
direction: Direction,
) -> Self {
let mut visited = BitSet::new_empty(graph.len_nodes());
let mut visited = DenseBitSet::new_empty(graph.len_nodes());
visited.insert(start_node.node_id());
DepthFirstTraversal { graph, stack: vec![start_node], visited, direction }
}

View File

@@ -1,6 +1,6 @@
use std::ops::ControlFlow;
use rustc_index::bit_set::BitSet;
use rustc_index::bit_set::DenseBitSet;
use rustc_index::{IndexSlice, IndexVec};
use super::{DirectedGraph, StartNode, Successors};
@@ -78,7 +78,7 @@ where
{
graph: G,
stack: Vec<G::Node>,
visited: BitSet<G::Node>,
visited: DenseBitSet<G::Node>,
}
impl<G> DepthFirstSearch<G>
@@ -86,7 +86,7 @@ where
G: DirectedGraph + Successors,
{
pub fn new(graph: G) -> Self {
Self { stack: vec![], visited: BitSet::new_empty(graph.num_nodes()), graph }
Self { stack: vec![], visited: DenseBitSet::new_empty(graph.num_nodes()), graph }
}
/// Version of `push_start_node` that is convenient for chained
@@ -207,8 +207,8 @@ where
{
graph: &'graph G,
stack: Vec<Event<G::Node>>,
visited: BitSet<G::Node>,
settled: BitSet<G::Node>,
visited: DenseBitSet<G::Node>,
settled: DenseBitSet<G::Node>,
}
impl<'graph, G> TriColorDepthFirstSearch<'graph, G>
@@ -219,8 +219,8 @@ where
TriColorDepthFirstSearch {
graph,
stack: vec![],
visited: BitSet::new_empty(graph.num_nodes()),
settled: BitSet::new_empty(graph.num_nodes()),
visited: DenseBitSet::new_empty(graph.num_nodes()),
settled: DenseBitSet::new_empty(graph.num_nodes()),
}
}