modified: ../../../../main/java/de/dhbwstuttgart/typeinference/unify/PartialOrderSet.java
modified: ../../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java PartialOrderSet als LinkedList realisiert modified: ../../bytecode/javFiles/Matrix.jav
This commit is contained in:
parent
0c03c2fbc8
commit
85a15cb256
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
@ -11,8 +13,8 @@ import com.google.common.collect.Ordering;
|
|||||||
|
|
||||||
public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
|
public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
|
||||||
|
|
||||||
HashSet<E> hs = new HashSet<>();
|
//HashSet<E> hs = new HashSet<>();
|
||||||
Vector<E> ve = new Vector<>();
|
List<E> ve = new LinkedList<>();//new Vector<>();
|
||||||
F ordering;
|
F ordering;
|
||||||
|
|
||||||
PartialOrderSet(F ordering) {
|
PartialOrderSet(F ordering) {
|
||||||
@ -23,6 +25,12 @@ public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
|
|||||||
this.ordering= ordering;
|
this.ordering= ordering;
|
||||||
this.addAll(s);
|
this.addAll(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PartialOrderSet(PartialOrderSet<E, F> pos) {
|
||||||
|
this.ordering= pos.ordering;
|
||||||
|
this.ve = new LinkedList<>(pos.ve);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return ve.size();
|
return ve.size();
|
||||||
@ -35,7 +43,7 @@ public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
return hs.contains(o);
|
return ve.contains(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,31 +65,35 @@ public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
|
|||||||
return new ArrayList<>(ve);
|
return new ArrayList<>(ve);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<E> toList() {
|
||||||
|
return new LinkedList<>(ve);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(E e) {
|
public boolean add(E e) {
|
||||||
if (this.contains(e)) {
|
if (this.contains(e)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hs.add(e);
|
//hs.add(e);
|
||||||
for(int i = 0; i< ve.size(); i++) {
|
for(int i = 0; i< ve.size(); i++) {
|
||||||
if (ordering.compare(e, ve.elementAt(i)) == -1) {
|
if (ordering.compare(e, ve.get(i)) == -1) {
|
||||||
ve.insertElementAt(e, i);
|
ve.add(i,e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ve.addElement(e);
|
ve.add(e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
hs.remove(o);
|
//hs.remove(o);
|
||||||
return ve.remove(o);
|
return ve.remove(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(Collection<?> c) {
|
public boolean containsAll(Collection<?> c) {
|
||||||
return hs.containsAll(c);
|
return ve.containsAll(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -97,19 +109,19 @@ public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
hs.retainAll(c);
|
//hs.retainAll(c);
|
||||||
return ve.retainAll(c);
|
return ve.retainAll(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
hs.removeAll(c);
|
//hs.removeAll(c);
|
||||||
return ve.removeAll(c);
|
return ve.removeAll(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
hs.clear();
|
//hs.clear();
|
||||||
ve.clear();
|
ve.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren
|
//PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren
|
||||||
//Typen getestet werden.
|
//Typen getestet werden.
|
||||||
writeLog(nOfUnify.toString() + " Oderconstraints2: " + oderConstraintsOutput.toString());
|
writeLog(nOfUnify.toString() + " Oderconstraints2: " + oderConstraintsOutput.toString());
|
||||||
if (printtag) System.out.println("secondLevelSets:" +secondLevelSets);
|
writeLog(nOfUnify.toString() + "secondLevelSets:" +secondLevelSets.toString());
|
||||||
// If pairs occured that did not match one of the cartesian product cases,
|
// If pairs occured that did not match one of the cartesian product cases,
|
||||||
// those pairs are contradictory and the unification is impossible.
|
// those pairs are contradictory and the unification is impossible.
|
||||||
if(!undefinedPairs.isEmpty()) {
|
if(!undefinedPairs.isEmpty()) {
|
||||||
@ -767,7 +767,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair> nextSet = remainingSets.remove(0);
|
PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair> nextSet = remainingSets.remove(0);
|
||||||
writeLog("nextSet: " + nextSet.toString());
|
writeLog("nextSet: " + nextSet.toString());
|
||||||
List<Set<UnifyPair>> nextSetasList = nextSet.toArrayList();
|
List<Set<UnifyPair>> nextSetasList = nextSet.toList();
|
||||||
try {
|
try {
|
||||||
//List<Set<UnifyPair>>
|
//List<Set<UnifyPair>>
|
||||||
//nextSetasList = oup.sortedCopy(nextSet);//new ArrayList<>(nextSet);
|
//nextSetasList = oup.sortedCopy(nextSet);//new ArrayList<>(nextSet);
|
||||||
@ -930,7 +930,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<TypeUnify2Task> forks = new HashSet<>();
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
||||||
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
||||||
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
//List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
||||||
|
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig =
|
||||||
|
oderConstraints.stream().map(x -> new PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>(x)).collect(Collectors.toList());
|
||||||
newElemsOrig.add(a);
|
newElemsOrig.add(a);
|
||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
@ -950,7 +952,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
Set<UnifyPair> newEq = new HashSet<>(eq);
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints = new ArrayList<>(oderConstraints);
|
//List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
|
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints =
|
||||||
|
oderConstraints.stream().map(x -> new PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>(x)).collect(Collectors.toList());
|
||||||
newElems.add(nSaL);
|
newElems.add(nSaL);
|
||||||
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
@ -986,7 +990,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<TypeUnify2Task> forks = new HashSet<>();
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
||||||
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
||||||
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
//List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
||||||
|
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig =
|
||||||
|
oderConstraints.stream().map(x -> new PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>(x)).collect(Collectors.toList());
|
||||||
newElemsOrig.add(a);
|
newElemsOrig.add(a);
|
||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
@ -1006,7 +1012,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
Set<UnifyPair> newEq = new HashSet<>(eq);
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints = new ArrayList<>(oderConstraints);
|
//List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
|
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints =
|
||||||
|
oderConstraints.stream().map(x -> new PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>(x)).collect(Collectors.toList());
|
||||||
newElems.add(nSaL);
|
newElems.add(nSaL);
|
||||||
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
@ -1043,7 +1051,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<TypeUnifyTask> forks = new HashSet<>();
|
Set<TypeUnifyTask> forks = new HashSet<>();
|
||||||
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
||||||
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
//List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
||||||
|
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraintsOrig =
|
||||||
|
oderConstraints.stream().map(x -> new PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>(x)).collect(Collectors.toList());
|
||||||
newElemsOrig.add(a);
|
newElemsOrig.add(a);
|
||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
@ -1061,7 +1071,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//nextSetasList.remove(nSaL);
|
//nextSetasList.remove(nSaL);
|
||||||
Set<UnifyPair> newEq = new HashSet<>(eq);
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints = new ArrayList<>(oderConstraints);
|
//List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
|
List<PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>> newOderConstraints =
|
||||||
|
oderConstraints.stream().map(x -> new PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair>(x)).collect(Collectors.toList());
|
||||||
newElems.add(nSaL);
|
newElems.add(nSaL);
|
||||||
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
@ -2240,8 +2252,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeLog(String str) {
|
synchronized void writeLog(String str) {
|
||||||
synchronized ( this ) {
|
|
||||||
if (log) {
|
if (log) {
|
||||||
try {
|
try {
|
||||||
logFile.write("Thread no.:" + thNo + "\n");
|
logFile.write("Thread no.:" + thNo + "\n");
|
||||||
@ -2254,7 +2265,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("kein LogFile");
|
System.err.println("kein LogFile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
//import java.lang.Float;
|
import java.lang.Float;
|
||||||
//import java.lang.Byte;
|
//import java.lang.Byte;
|
||||||
//import java.lang.Boolean;
|
//import java.lang.Boolean;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user