main() const circuit c = input_circuit(std::cin) circuit_inputs ci; while (input_inputs(std::cin, ci)) output_results( std::cout, analyze(c, ci, emsg))
circuit
circuit-inputs
analysis-results
input-circuit()
input-inputs()
analyze()
output_results()
in0 in1 in2 and0 not0 and1 or1 out0
// Add the given edge to the this graph. void add-edge(from, to, err) // Create a new, empty circuit. circuit(); // Return this circuit's maximum delay. unsigned maximum-delay() const // Trace the inputs through this circuit, // return the outputs. circuit-inputs trace(inputs) const;
graph g; graph::vertex-label-set input-ports, output-ports; mutable int max-delay; mutable sequence<graph::vertex-label-type> schedule; static const graph::vertex-label-type source-node, sink-node;
typedef std::string vertex_label_type; typedef set<vertex_label_type> vertex_label_set void add_edge(from, to, err) vertex_label_set incoming_nodes(label) const vertex_label_set outgoing_nodes(label) const const vertex_label_set & vertices() const
table<vertex-label-type, sequence<vertex-label-type> incoming, outgoing vertex-label-set nodes vertex-label-set graph::incoming_nodes( const vertex-label-type & label) return incoming.get(label)
Tests | ||||||||||
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
1 | ||||||||||
2 |
int checkForBlankLine(string inputLine) int spaces = 0 while (spaces < inputLine.length()) and isspace(inputLine[spaces]) spaces++ if spaces == inputLine.length() return -1 return spaces++
int checkForBlankLine(string inputLine) const unsigned n = inputLine.find_first_not_of(" \n\t"); return n == string::npos ? -1 : n;
struct Circuit_or_Port Circuit_or_Port(const Circuit_or_Port &) ~Circuit_or_Port() void operator =(const Circuit_or_Port &) void addAjacentLabel(adjacentLabel * &) void addComponent(Circuit_or_Port * &) string circuitOrPortType int propagationTime bool visited int receivedInputs int valueOfInputs int valueOfOutputs int noOfInputWires int noOfOutputWires int currentInputWireArraySize int currentOutputWireArraySize int* inputWires string* receivedFrom adjacentLabel * adjacentVertex Circuit_or_Port * nextVertex
struct graph public: graph() graph(const graph& agraph) ~graph() void operator = (const graph & agraph) gate* addgate(string, string) gate* addgate(string, string, gate *) gate* getgate(int index) int getsize() int getisize() int getosize() gate* gatesearch(string aname) void addin(gate*) void addout(gate*) void init(int thesize) bool eval(bool ins[], bool outs[], int& del) void reset() void pprint()