From 25b1d3e62d1d7cd3fc9a26ba41eedade5c3b15a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Thu, 14 Feb 2019 08:53:32 +0100 Subject: [PATCH] modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java ArrayList durch LinkedList ersetzt computeCartesianRecursiveOderConstraints auskommentiert --- .../typeinference/unify/TypeUnifyTask.java | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 77ca34d4..351bb0bf 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -228,7 +228,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } */ - +/* public Set> computeCartesianRecursiveOderConstraints(Set> fstElems, List>> topLevelSets, IFiniteClosure fc, boolean parallel, int rekTiefe) { //ArrayList>> remainingSets = new ArrayList<>(topLevelSets); fstElems.addAll(topLevelSets.stream() @@ -274,7 +274,8 @@ public class TypeUnifyTask extends RecursiveTask>> { // nextSetasList = al; //} //Set a = nextSetasListIt.next(); - /*if (nextSetasList.size()>1) {zu loeschen + // + / *if (nextSetasList.size()>1) {zu loeschen if (nextSetasList.iterator().next().iterator().next().getLhsType().getName().equals("D")) System.out.print(""); if (variance == 1) { @@ -290,7 +291,7 @@ public class TypeUnifyTask extends RecursiveTask>> { else { a_next = nextSetasList.iterator().next(); } - */ + * / if (!nextSetasList.iterator().hasNext()) System.out.print(""); if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1) @@ -299,11 +300,13 @@ public class TypeUnifyTask extends RecursiveTask>> { while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) { Set a = null; if (variance == 1) { - a = oup.max(nextSetasList.iterator()); + //a = oup.max(nextSetasList.iterator()); + a = nextSetasList.get(nextSetasList.size()-1); nextSetasList.remove(a); } else if (variance == -1) { - a = oup.min(nextSetasList.iterator()); + //a = oup.min(nextSetasList.iterator()); + a = nextSetasList.get(0); nextSetasList.remove(a); } else if (variance == 0) { @@ -311,7 +314,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } //writeLog("nextSet: " + nextSetasList.toString()+ "\n"); //nextSetasList.remove(a); - /* zu loeschen + / * zu loeschen if (nextSetasList.size() > 0) { if (nextSetasList.size()>1) { if (variance == 1) { @@ -328,7 +331,7 @@ public class TypeUnifyTask extends RecursiveTask>> { a_next = nextSetasList.iterator().next(); } } - */ + * / //PL 2018-03-01 //TODO: 1. Maximum und Minimum unterscheiden //TODO: 2. compare noch für alle Elmemente die nicht X =. ty sind erweitern @@ -372,7 +375,7 @@ public class TypeUnifyTask extends RecursiveTask>> { - /* auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG */ + / * auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG * / if (!result.isEmpty() && !isUndefinedPairSetSet(res)) { if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1) System.out.print(""); @@ -407,9 +410,9 @@ public class TypeUnifyTask extends RecursiveTask>> { //break; }} } - /* auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */ + / * auskommentiert um alle Max und min Betrachtung auszuschalten ENDE * / - /* PL 2018-11-05 wird falsch weil es auf der obersten Ebene ist. + / * PL 2018-11-05 wird falsch weil es auf der obersten Ebene ist. if (isUndefinedPairSetSet(res)) { int nofstred= 0; Set abhSubst = res.stream() @@ -462,7 +465,7 @@ public class TypeUnifyTask extends RecursiveTask>> { writeLog("Number of Backtracking: " + noBacktracking); System.out.println(""); } - */ + * / //if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) { // return result; //} @@ -475,7 +478,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } // End of while (nextSetasList.size() > 0) return result; } - + */ /** * Computes all principal type unifiers for a set of constraints. @@ -820,15 +823,15 @@ public class TypeUnifyTask extends RecursiveTask>> { Set a = null; while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) { Set a_last = a; - List> nextSetasListRest = new ArrayList<>(); + List> nextSetasListRest = new LinkedList<>(); //List> nextSetasListRestMin = new ArrayList<>(); //List> nextSetasListRestOder = new ArrayList<>(); if (variance == 1) { //a = oup.max(nextSetasList.iterator()); a = nextSetasList.get(nextSetasList.size()-1); nextSetasList.remove(a); - nextSetasListRest = new ArrayList<>(nextSetasList); - Iterator> nextSetasListItRest = new ArrayList>(nextSetasListRest).iterator(); + nextSetasListRest = new LinkedList<>(nextSetasList); + Iterator> nextSetasListItRest = new LinkedList>(nextSetasListRest).iterator(); while (nextSetasListItRest.hasNext()) { Set a_next = nextSetasListItRest.next(); if (//a.equals(a_next) || @@ -839,9 +842,10 @@ public class TypeUnifyTask extends RecursiveTask>> { //Alle maximale Elemente in nextSetasListRest bestimmen List> nextSetasListRestTest; do { - nextSetasListRestTest = new ArrayList>(nextSetasListRest); + nextSetasListRestTest = new LinkedList>(nextSetasListRest); if (!nextSetasListRest.isEmpty()) { - Set max = oup.max(nextSetasListRest.iterator()); + //Set max = oup.max(nextSetasListRest.iterator()); + Set max = nextSetasListRest.get(nextSetasListRest.size()-1); Iterator> nextSetasListItRest2 = new ArrayList>(nextSetasListRest).iterator(); while (nextSetasListItRest2.hasNext()) { Set a_nextRest = nextSetasListItRest2.next(); @@ -858,7 +862,7 @@ public class TypeUnifyTask extends RecursiveTask>> { //a = oup.min(nextSetasList.iterator()); a = nextSetasList.get(0); nextSetasList.remove(a); - nextSetasListRest = new ArrayList<>(nextSetasList); + nextSetasListRest = new LinkedList<>(nextSetasList); Iterator> nextSetasListItRest = new ArrayList>(nextSetasListRest).iterator(); while (nextSetasListItRest.hasNext()) { Set a_next = nextSetasListItRest.next(); @@ -871,9 +875,10 @@ public class TypeUnifyTask extends RecursiveTask>> { List> nextSetasListRestTest; do { - nextSetasListRestTest = new ArrayList>(nextSetasListRest); + nextSetasListRestTest = new LinkedList>(nextSetasListRest); if (!nextSetasListRest.isEmpty()) { - Set min = oup.min(nextSetasListRest.iterator()); + //Set min = oup.min(nextSetasListRest.iterator()); + Set min = nextSetasListRest.get(0); Iterator> nextSetasListItRest2 = new ArrayList>(nextSetasListRest).iterator(); while (nextSetasListItRest2.hasNext()) { Set a_nextRest = nextSetasListItRest2.next(); @@ -887,7 +892,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } else if (variance == 2) { a = nextSetasList.remove(0); - nextSetasListRest = new ArrayList<>(nextSetasList); + nextSetasListRest = new LinkedList<>(nextSetasList); } else if (variance == 0) { a = nextSetasList.remove(0);