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:
Martin Plümicke 2019-02-13 18:34:12 +01:00
parent 0c03c2fbc8
commit 85a15cb256
3 changed files with 47 additions and 25 deletions

View File

@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
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> {
HashSet<E> hs = new HashSet<>();
Vector<E> ve = new Vector<>();
//HashSet<E> hs = new HashSet<>();
List<E> ve = new LinkedList<>();//new Vector<>();
F ordering;
PartialOrderSet(F ordering) {
@ -23,6 +25,12 @@ public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
this.ordering= ordering;
this.addAll(s);
}
PartialOrderSet(PartialOrderSet<E, F> pos) {
this.ordering= pos.ordering;
this.ve = new LinkedList<>(pos.ve);
}
@Override
public int size() {
return ve.size();
@ -35,7 +43,7 @@ public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
@Override
public boolean contains(Object o) {
return hs.contains(o);
return ve.contains(o);
}
@Override
@ -57,31 +65,35 @@ public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
return new ArrayList<>(ve);
}
public List<E> toList() {
return new LinkedList<>(ve);
}
@Override
public boolean add(E e) {
if (this.contains(e)) {
return false;
}
hs.add(e);
//hs.add(e);
for(int i = 0; i< ve.size(); i++) {
if (ordering.compare(e, ve.elementAt(i)) == -1) {
ve.insertElementAt(e, i);
if (ordering.compare(e, ve.get(i)) == -1) {
ve.add(i,e);
return true;
}
}
ve.addElement(e);
ve.add(e);
return true;
}
@Override
public boolean remove(Object o) {
hs.remove(o);
//hs.remove(o);
return ve.remove(o);
}
@Override
public boolean containsAll(Collection<?> c) {
return hs.containsAll(c);
return ve.containsAll(c);
}
@Override
@ -97,19 +109,19 @@ public class PartialOrderSet<E, F extends Ordering<E>> implements Set<E> {
@Override
public boolean retainAll(Collection<?> c) {
hs.retainAll(c);
//hs.retainAll(c);
return ve.retainAll(c);
}
@Override
public boolean removeAll(Collection<?> c) {
hs.removeAll(c);
//hs.removeAll(c);
return ve.removeAll(c);
}
@Override
public void clear() {
hs.clear();
//hs.clear();
ve.clear();
}

View File

@ -571,7 +571,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren
//Typen getestet werden.
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,
// those pairs are contradictory and the unification is impossible.
if(!undefinedPairs.isEmpty()) {
@ -767,7 +767,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}
PartialOrderSet<Set<UnifyPair>,OrderingUnifyPair> nextSet = remainingSets.remove(0);
writeLog("nextSet: " + nextSet.toString());
List<Set<UnifyPair>> nextSetasList = nextSet.toArrayList();
List<Set<UnifyPair>> nextSetasList = nextSet.toList();
try {
//List<Set<UnifyPair>>
//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<UnifyPair> newEqOrig = new HashSet<>(eq);
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);
/* FORK ANFANG */
@ -950,7 +952,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}
Set<UnifyPair> newEq = new HashSet<>(eq);
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);
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
forks.add(fork);
@ -986,7 +990,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
Set<TypeUnify2Task> forks = new HashSet<>();
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
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);
/* FORK ANFANG */
@ -1006,7 +1012,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}
Set<UnifyPair> newEq = new HashSet<>(eq);
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);
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
forks.add(fork);
@ -1043,7 +1051,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
Set<TypeUnifyTask> forks = new HashSet<>();
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
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);
/* FORK ANFANG */
@ -1061,7 +1071,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//nextSetasList.remove(nSaL);
Set<UnifyPair> newEq = new HashSet<>(eq);
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);
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
forks.add(fork);
@ -2240,8 +2252,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}
}
void writeLog(String str) {
synchronized ( this ) {
synchronized void writeLog(String str) {
if (log) {
try {
logFile.write("Thread no.:" + thNo + "\n");
@ -2254,7 +2265,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
catch (IOException e) {
System.err.println("kein LogFile");
}
}
}
}
}
}

View File

@ -1,6 +1,6 @@
import java.util.Vector;
import java.lang.Integer;
//import java.lang.Float;
import java.lang.Float;
//import java.lang.Byte;
//import java.lang.Boolean;