From 5d39863cc6d251a824d742ec7c11796e63fe572b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Tue, 20 Mar 2018 22:30:57 +0100 Subject: [PATCH] modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java Maximumsbildung auf maximale Elemente soweit fertig Argument von mul funktion nicht, liefret nur Vec --- .../typeinference/unify/TypeUnifyTask.java | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index fb3aa1ab..73f6eff9 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; @@ -310,17 +311,22 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> computeCartesianRecursive(Set> fstElems, ArrayList>> topLevelSets, Set eq, IFiniteClosure fc, boolean parallel) { ArrayList>> remainingSets = new ArrayList<>(topLevelSets); Set> nextSet = remainingSets.remove(0); - ArrayList> nextSetasList = new ArrayList<>(nextSet); + List> nextSetasList = oup.sortedCopy(nextSet);//new ArrayList<>(nextSet); Set> result = new HashSet<>(); - int i = 0; byte variance = nextSetasList.iterator().next().iterator().next().getVariance(); - Set a_next = null; - if (nextSetasList.size()>1) { + if (variance == 1 && nextSetasList.size() > 1) { + List> al = new ArrayList<>(nextSetasList.size()); + for (int ii = 0; ii < nextSetasList.size();ii++) { + al.add(0,nextSetasList.get(ii)); + } + nextSetasList = al; + } + //Set a = nextSetasListIt.next(); + /*if (nextSetasList.size()>1) {zu loeschen if (nextSetasList.iterator().next().iterator().next().getLhsType().getName().equals("D")) System.out.print(""); if (variance == 1) { a_next = oup.max(nextSetasList.iterator()); - List> liup = oup.sortedCopy(nextSetasList); } else if (variance == -1) { a_next = oup.min(nextSetasList.iterator()); @@ -332,12 +338,14 @@ public class TypeUnifyTask extends RecursiveTask>> { else { a_next = nextSetasList.iterator().next(); } + */ if (nextSetasList.iterator().next().iterator().next().getLhsType().getName().equals("D") && nextSetasList.size()>1) System.out.print(""); - while (nextSetasList.size() != 0) { - Set a = a_next; + while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) { + Set a = nextSetasList.remove(0); //writeLog("nextSet: " + nextSetasList.toString()+ "\n"); - nextSetasList.remove(a); + //nextSetasList.remove(a); + /* zu loeschen if (nextSetasList.size() > 0) { if (nextSetasList.size()>1) { if (variance == 1) { @@ -354,6 +362,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 @@ -370,27 +379,23 @@ public class TypeUnifyTask extends RecursiveTask>> { } if (!result.isEmpty() && !isUndefinedPairSetSet(result)) { + Iterator> nextSetasListIt = new ArrayList>(nextSetasList).iterator(); if (variance == 1) { - if (a.iterator().next().getLhsType().getName().equals("WL")) - System.out.print(""); - if (a.equals(a_next) || + while (nextSetasListIt.hasNext()) { + Set a_next = nextSetasListIt.next(); + if (a.equals(a_next) || (oup.compare(a, a_next) == 1)) { - System.out.print(""); - break; - } - else { - System.out.print(""); + nextSetasList.remove(a_next); + } } } else { if (variance == -1) { - if (a.iterator().next().getLhsType().getName().equals("A")) - System.out.print(""); - if (a.equals(a_next) || (oup.compare(a, a_next) == -1)) { - System.out.print(""); - break; - } - else { - System.out.print(""); + while (nextSetasListIt.hasNext()) { + Set a_next = nextSetasListIt.next(); + if (a.equals(a_next) || + (oup.compare(a, a_next) == -1)) { + nextSetasList.remove(0); + } } } else if (variance == 0) {