1
Fork 0

don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead

This commit is contained in:
klensy 2023-08-21 15:07:18 +03:00
parent 9847c6406d
commit 3b26b3d1d2

View file

@ -20,7 +20,6 @@
//! the field `next_edge`). Each of those fields is an array that should //! the field `next_edge`). Each of those fields is an array that should
//! be indexed by the direction (see the type `Direction`). //! be indexed by the direction (see the type `Direction`).
use crate::snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
use rustc_index::bit_set::BitSet; use rustc_index::bit_set::BitSet;
use std::fmt::Debug; use std::fmt::Debug;
@ -28,8 +27,8 @@ use std::fmt::Debug;
mod tests; mod tests;
pub struct Graph<N, E> { pub struct Graph<N, E> {
nodes: SnapshotVec<Node<N>>, nodes: Vec<Node<N>>,
edges: SnapshotVec<Edge<E>>, edges: Vec<Edge<E>>,
} }
pub struct Node<N> { pub struct Node<N> {
@ -45,20 +44,6 @@ pub struct Edge<E> {
pub data: E, pub data: E,
} }
impl<N> SnapshotVecDelegate for Node<N> {
type Value = Node<N>;
type Undo = ();
fn reverse(_: &mut Vec<Node<N>>, _: ()) {}
}
impl<N> SnapshotVecDelegate for Edge<N> {
type Value = Edge<N>;
type Undo = ();
fn reverse(_: &mut Vec<Edge<N>>, _: ()) {}
}
#[derive(Copy, Clone, PartialEq, Debug)] #[derive(Copy, Clone, PartialEq, Debug)]
pub struct NodeIndex(pub usize); pub struct NodeIndex(pub usize);
@ -86,11 +71,11 @@ impl NodeIndex {
impl<N: Debug, E: Debug> Graph<N, E> { impl<N: Debug, E: Debug> Graph<N, E> {
pub fn new() -> Graph<N, E> { pub fn new() -> Graph<N, E> {
Graph { nodes: SnapshotVec::new(), edges: SnapshotVec::new() } Graph { nodes: Vec::new(), edges: Vec::new() }
} }
pub fn with_capacity(nodes: usize, edges: usize) -> Graph<N, E> { pub fn with_capacity(nodes: usize, edges: usize) -> Graph<N, E> {
Graph { nodes: SnapshotVec::with_capacity(nodes), edges: SnapshotVec::with_capacity(edges) } Graph { nodes: Vec::with_capacity(nodes), edges: Vec::with_capacity(edges) }
} }
// # Simple accessors // # Simple accessors