[−][src]Struct egg::EGraph
Data structure to keep track of equalities between expressions.
An egraph (EGraph
) is a data structure to maintain equivalence
classes of expressions.
An egraph conceptually is a set of eclasses (EClass
) each of which
contains equivalent enodes (ENode
).
An enode is conceptually and operator with children, but instead of children being other operators or values, the children are eclasses.
Methods
impl<L, M> EGraph<L, M>
[src]
pub fn classes(&self) -> impl Iterator<Item = &EClass<L, M>>
[src]
pub fn classes_mut(&mut self) -> impl Iterator<Item = &mut EClass<L, M>>
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn total_size(&self) -> usize
[src]
Returns the number of nodes in the EGraph
.
Actually returns the size of the hash cons index.
let mut egraph = EGraph::<&str, ()>::default(); let x = egraph.add(enode!("x")); let y = egraph.add(enode!("y")); // only one eclass egraph.union(x, y); assert_eq!(egraph.total_size(), 2);
pub fn number_of_classes(&self) -> usize
[src]
pub fn find(&self, id: Id) -> Id
[src]
pub fn dot(&self) -> Dot<L, M>
[src]
impl<L: Language, M: Metadata<L>> EGraph<L, M>
[src]
pub fn from_expr(expr: &RecExpr<L>) -> (Self, Id)
[src]
pub fn add_expr(&mut self, expr: &RecExpr<L>) -> Id
[src]
pub fn add(&mut self, enode: ENode<L>) -> Id
[src]
pub fn equivs(&self, expr1: &RecExpr<L>, expr2: &RecExpr<L>) -> Vec<Id>
[src]
pub fn rebuild(&mut self)
[src]
pub fn union(&mut self, id1: Id, id2: Id) -> Id
[src]
pub fn union_if_different(&mut self, id1: Id, id2: Id) -> Option<Id>
[src]
pub fn dump<'a>(&'a self) -> impl Debug + 'a
[src]
Trait Implementations
impl<L: Clone, M: Clone> Clone for EGraph<L, M>
[src]
impl<L: Language, M: Debug> Debug for EGraph<L, M>
[src]
impl<L, M> Default for EGraph<L, M>
[src]
impl<L: Language, M> Index<u32> for EGraph<L, M>
[src]
Auto Trait Implementations
impl<L, M> !RefUnwindSafe for EGraph<L, M>
impl<L, M> Send for EGraph<L, M> where
L: Send,
M: Send,
L: Send,
M: Send,
impl<L, M> !Sync for EGraph<L, M>
impl<L, M> Unpin for EGraph<L, M> where
L: Unpin,
M: Unpin,
L: Unpin,
M: Unpin,
impl<L, M> UnwindSafe for EGraph<L, M> where
L: UnwindSafe,
M: UnwindSafe,
L: UnwindSafe,
M: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,