Trait mcircuit::Translatable
source · [−]pub trait Translatable {
fn translate<I1, I2>(&self, win: I1, wout: I2) -> Option<Self>
where
Self: Sized,
I1: Iterator<Item = usize>,
I2: Iterator<Item = usize>;
fn translate_from_hashmap<'a>(
&'a self,
translation_table: HashMap<usize, usize>
) -> Option<Self>
where
Self: Sized + HasIO,
InputIterator<'a, Self>: Iterator<Item = usize>,
OutputIterator<'a, Self>: Iterator<Item = usize>,
{ ... }
fn translate_from_fn<'a>(
&'a self,
input_mapper: fn(_: usize) -> usize,
output_mapper: fn(_: usize) -> usize
) -> Option<Self>
where
Self: Sized + HasIO,
InputIterator<'a, Self>: Iterator<Item = usize>,
OutputIterator<'a, Self>: Iterator<Item = usize>,
{ ... }
}
Expand description
Defines a number of helper methods for replacing the I/O wires on a gate with new ones
Required methods
takes an iterator of input wires and an iterator of output wires, and creates a new gate of the same type using the inputs and outputs. The current input and output wires have no bearing on the new wires, just the gate type.
Provided methods
Takes a hashmap, and looks for existing wires in the keys. Replaces any existing wire keys with the value from the hashmap.
Calls a function on the I/O wires and replaces them with the output of the function.