pub struct Gate(/* private fields */);Expand description
A gate in a boolean circuit.
The inputs of the circuit are variables identified by their name. Other types of gates are constant gates or operations that have predecessors.
The clone operation only performs a shallow clone and thus allows sharing of gates.
Implementations§
Source§impl Gate
impl Gate
Sourcepub fn id(&self) -> usize
pub fn id(&self) -> usize
Returns an identifier for the gate which is unique in the circuit but not stable across program reloads.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Gate>
pub fn iter(&self) -> impl Iterator<Item = &Gate>
Creates an iterator over the graph (the gate itself and all its predecessors) that returns each gate exactly once.
Sourcepub fn post_visit_iter(&self) -> impl Iterator<Item = &Gate>
pub fn post_visit_iter(&self) -> impl Iterator<Item = &Gate>
Creates an iterator over the graph (the gate itself and all its predecessors) with post-visit order, visiting each gate exactly once. This means that the predecessors of each gate are always visited before the gate itself.
Sourcepub fn to_string_as_tree(&self) -> String
pub fn to_string_as_tree(&self) -> String
Turns the gate and its predecessors into a string representation, repeating shared gates.
Sourcepub fn try_to_constant(&self) -> Option<bool>
pub fn try_to_constant(&self) -> Option<bool>
Returns the value of the gate if it is a constant input gate.
Sourcepub fn gate_count(&self) -> (usize, usize)
pub fn gate_count(&self) -> (usize, usize)
Returns the number of variables and inner gates (gates not counting variables or constants) in the circuit.
This depends on how the circuit was constructed, i.e. it does not deduplicate sub-circuits, but it does deduplicate variables with the same name.
Trait Implementations§
Source§impl<'a> IntoIterator for &'a Gate
impl<'a> IntoIterator for &'a Gate
Auto Trait Implementations§
impl Freeze for Gate
impl RefUnwindSafe for Gate
impl !Send for Gate
impl !Sync for Gate
impl Unpin for Gate
impl UnwindSafe for Gate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more