Compare commits

...

2 commits

Author SHA1 Message Date
b635c13d57 Dev from a brand new PC 2025-05-08 21:34:10 +02:00
02c1adbcbf dev localy 2025-05-08 21:23:40 +02:00
4 changed files with 19 additions and 20 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -28,7 +28,7 @@ public class GraphGenerator {
public static class Graph{
private static Pattern PATTERN = Pattern.compile("^(\\d+)\\s+->\s+(.*)$");
private static Pattern PATTERN = Pattern.compile("^(\\d+)\\s+->\\s+(.*)$");
private List<Node> nodes;

View file

@ -18,9 +18,7 @@ public class Operator{
VisitorBag vbag = visitor.visit(element);
if(!vbag.isValidated()) return new VisitorBag();
bag.merge(vbag);
for(Object computed : vbag.computeList()){
set.add(computed);
}
set.add(vbag.computed());
}
for(Object obj : set) bag.compute(obj);
return bag;
@ -53,9 +51,7 @@ public class Operator{
VisitorBag vbag = visitor.visit(element);
if(!vbag.isValidated()) return new VisitorBag();
bag.merge(vbag);
for(Object computed : vbag.computeList()){
bag.compute(computed);
}
bag.compute(vbag.computed());
return bag;
}
return bag;
@ -94,7 +90,7 @@ public class Operator{
@Override
public boolean canPropagate(){
return true;
return visitor.canPropagate();
}
};
}
@ -108,7 +104,6 @@ public class Operator{
@Override
public boolean canVisit(Class<?> type){
// System.out.println("collect can visit ? "+type);
return visitor.canVisit(type);
}

View file

@ -9,35 +9,39 @@ import java.util.Map;
//only one pass in parameter or visit ?
public class VisitorBag{
private static final Object VALIDATE_BAG = new Object();
private static final Object VALIDATED_BAG = new Object();
private List<Object> collect;
private Object computed;
public VisitorBag(){
this.collect = new ArrayList<>();
this.collect = new ArrayList<>(0);
}
public void compute(Object element){
this.computed = element;
}
VisitorBag pair(Object key){
this.collect = Arrays.asList(new Pair<>(key, collect));
return this;
}
public void merge(VisitorBag bag){
this.collect.addAll(bag.collect);
if(!this.collect.isEmpty()) this.computed = VALIDATE_BAG;
if((!this.collect.isEmpty()) && this.computed == null) this.computed = VALIDATED_BAG;
}
public Object computed(){
return this.computed;
}
public boolean isValidated(){
return this.VALIDATE_BAG != null;
return this.computed != null;
}
VisitorBag pair(Object key){
this.collect = Arrays.asList(new Pair<>(key, this.collect));
return this;
}
VisitorBag collect(){
this.collect.addAll(this.list);
if(this.computed != null) this.collect.add(this.computed);
return this;
}