use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class FileStatistics method doSimpleCount.
private static Map<ComponentFactory, Count> doSimpleCount(Circuit circuit) {
Map<ComponentFactory, Count> counts;
counts = new HashMap<ComponentFactory, Count>();
for (Component comp : circuit.getNonWires()) {
ComponentFactory factory = comp.getFactory();
Count count = counts.get(factory);
if (count == null) {
count = new Count(factory);
counts.put(factory, count);
}
count.simpleCount++;
}
return counts;
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class ReplacementMap method append.
void append(ReplacementMap next) {
for (Map.Entry<Component, HashSet<Component>> e : next.map.entrySet()) {
Component b = e.getKey();
// what b is replaced by
HashSet<Component> cs = e.getValue();
// what was replaced
HashSet<Component> as = this.inverse.remove(b);
// to get b
if (as == null) {
// b pre-existed replacements so
// we say it replaces itself.
as = new HashSet<Component>(3);
as.add(b);
}
for (Component a : as) {
HashSet<Component> aDst = this.map.get(a);
if (aDst == null) {
// should happen when b pre-existed only
aDst = new HashSet<Component>(cs.size());
this.map.put(a, aDst);
}
aDst.remove(b);
aDst.addAll(cs);
}
for (Component c : cs) {
// should always
HashSet<Component> cSrc = this.inverse.get(c);
// be null
if (cSrc == null) {
cSrc = new HashSet<Component>(as.size());
this.inverse.put(c, cSrc);
}
cSrc.addAll(as);
}
}
for (Map.Entry<Component, HashSet<Component>> e : next.inverse.entrySet()) {
Component c = e.getKey();
if (!inverse.containsKey(c)) {
HashSet<Component> bs = e.getValue();
if (!bs.isEmpty()) {
logger.error("Internal error: component replaced but not represented");
}
inverse.put(c, new HashSet<Component>(3));
}
}
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class ReplacementMap method put.
public void put(Component prev, Collection<? extends Component> next) {
if (frozen) {
throw new IllegalStateException("cannot change map after frozen");
}
HashSet<Component> repl = map.get(prev);
if (repl == null) {
repl = new HashSet<Component>(next.size());
map.put(prev, repl);
}
repl.addAll(next);
for (Component n : next) {
repl = inverse.get(n);
if (repl == null) {
repl = new HashSet<Component>(3);
inverse.put(n, repl);
}
repl.add(prev);
}
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class CircuitMutatorImpl method clear.
public void clear(Circuit circuit) {
HashSet<Component> comps = new HashSet<Component>(circuit.getNonWires());
comps.addAll(circuit.getWires());
if (!comps.isEmpty())
modified.add(circuit);
log.add(CircuitChange.clear(circuit, comps));
ReplacementMap repl = new ReplacementMap();
for (Component comp : comps) repl.remove(comp);
getMap(circuit).append(repl);
circuit.mutatorClear();
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class CircuitState method tick.
boolean tick(int ticks) {
boolean ret = false;
for (Component clock : circuit.getClocks()) {
ret |= Clock.tick(this, ticks, clock);
}
CircuitState[] subs = new CircuitState[substates.size()];
for (CircuitState substate : substates.toArray(subs)) {
ret |= substate.tick(ticks);
}
return ret;
}
Aggregations