modified: ../src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
new file: ../src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingExtend.java
This commit is contained in:
parent
907ab2fcec
commit
8e2d4e1c70
@ -723,6 +723,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
nextSetasListRest.remove(a_next);
|
||||
}
|
||||
}
|
||||
|
||||
List<Set<UnifyPair>> maxElementsTest = oup.maxElements(nextSetasListRest);
|
||||
//Alle maximale Elemente in nextSetasListRest bestimmen
|
||||
List<Set<UnifyPair>> nextSetasListRestTest;
|
||||
do {
|
||||
@ -739,7 +741,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
|
||||
}}
|
||||
} while(!nextSetasListRestTest.equals(nextSetasListRest));
|
||||
|
||||
writeLog("maxElementsTest: " + maxElementsTest.equals(nextSetasListRest));
|
||||
}
|
||||
else if (variance == -1) {
|
||||
a = oup.min(nextSetasList.iterator());
|
||||
@ -759,7 +761,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
}
|
||||
}
|
||||
//Alle minimalen Elemente in nextSetasListRest bestimmen
|
||||
|
||||
List<Set<UnifyPair>> minElementsTest = oup.minElements(nextSetasListRest);
|
||||
List<Set<UnifyPair>> nextSetasListRestTest;
|
||||
do {
|
||||
nextSetasListRestTest = new ArrayList<Set<UnifyPair>>(nextSetasListRest);
|
||||
@ -775,6 +777,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
|
||||
}}
|
||||
} while(!nextSetasListRestTest.equals(nextSetasListRest));
|
||||
writeLog("minElementsTest: " + minElementsTest.equals(nextSetasListRest));
|
||||
}
|
||||
else if (variance == 2) {
|
||||
a = nextSetasList.remove(0);
|
||||
|
@ -0,0 +1,89 @@
|
||||
package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class OrderingExtend<T> extends com.google.common.collect.Ordering<T> {
|
||||
|
||||
public List<T> maxElements(Iterable<T> iterable) {
|
||||
ArrayList<T> ret = new ArrayList<>();
|
||||
while (iterable.iterator().hasNext()) {
|
||||
Set<T> believe = new HashSet<>();
|
||||
|
||||
T max = max(iterable);
|
||||
ret.add(max);
|
||||
|
||||
Iterator<T> it = iterable.iterator();
|
||||
while (it.hasNext()) {
|
||||
T elem = it.next();
|
||||
if (!(compare(max, elem) == 1) && !max.equals(elem)) {
|
||||
believe.add(elem);
|
||||
}
|
||||
}
|
||||
iterable = believe;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<T> minElements(Iterable<T> iterable) {
|
||||
ArrayList<T> ret = new ArrayList<>();
|
||||
while (iterable.iterator().hasNext()) {
|
||||
Set<T> believe = new HashSet<>();
|
||||
|
||||
T min = min(iterable);
|
||||
ret.add(min);
|
||||
|
||||
Iterator<T> it = iterable.iterator();
|
||||
while (it.hasNext()) {
|
||||
T elem = it.next();
|
||||
if (!(compare(min, elem) == -1) && !min.equals(elem)) {
|
||||
believe.add(elem);
|
||||
}
|
||||
}
|
||||
iterable = believe;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public List<T> smallerEqThan(T elem, Iterable<T> iterable) {
|
||||
List<T> ret = smallerThan(elem, iterable);
|
||||
ret.add(elem);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
public List<T> smallerThan(T elem, Iterable<T> iterable) {
|
||||
ArrayList<T> ret = new ArrayList<>();
|
||||
Iterator<T> it = iterable.iterator();
|
||||
while (it.hasNext()) {
|
||||
T itElem = it.next();
|
||||
if (!itElem.equals(elem) && compare(elem, itElem) == 1) {
|
||||
ret.add(itElem);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<T> greaterEqThan(T elem, Iterable<T> iterable) {
|
||||
List<T> ret = greaterThan(elem, iterable);
|
||||
ret.add(elem);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
public List<T> greaterThan(T elem, Iterable<T> iterable) {
|
||||
ArrayList<T> ret = new ArrayList<>();
|
||||
Iterator<T> it = iterable.iterator();
|
||||
while (it.hasNext()) {
|
||||
T itElem = it.next();
|
||||
if (!itElem.equals(elem) && (compare(elem, itElem) == -1)) {
|
||||
ret.add(itElem);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user