package ex;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class PSC_Sample {

    public void testPSC(List<PSC_Sample> samples) {
        Set<String> names = new HashSet<String>();
        for (PSC_Sample s : samples) {
            names.add(s.toString());
        }
    }

    public void testPSCMaps(Map<String, String> input) {
        Map<String, String> output = new HashMap<String, String>();
        for (Map.Entry<String, String> entry : input.entrySet()) {
            output.put(entry.getKey().intern(), entry.getValue());
        }
    }

    public void testPSCEnumerated() {
        Set<String> commonWords = new HashSet<String>();
        commonWords.add("a");
        commonWords.add("an");
        commonWords.add("the");
        commonWords.add("by");
        commonWords.add("of");
        commonWords.add("and");
        commonWords.add("or");
        commonWords.add("in");
        commonWords.add("with");
        commonWords.add("my");
        commonWords.add("I");
        commonWords.add("on");
        commonWords.add("over");
        commonWords.add("under");
        commonWords.add("it");
        commonWords.add("they");
        commonWords.add("them");
    }

    public List<String> testAddAllToCtor(List<String> l) {
        List<String> ll = new ArrayList<String>();
        ll.addAll(l);

        ll.add("FooBar");
        return ll;
    }

    public void fpDontHaveCollectionForSizing(Iterator<Long> it) {
        Deque<Long> ad = new ArrayDeque<Long>();
        while (it.hasNext()) {
            ad.add(it.next());
        }
    }

    public void fpConditionalInLoop(Set<String> source) {
        List<String> dest = new ArrayList<String>();
        for (String s : source) {
            if (s.length() > 0) {
                dest.add(s);
            }
        }
    }

    public List<String> fpAddSubCollection(Map<String, Set<String>> s) {
        List<String> l = new ArrayList<String>();
        for (Map.Entry<String, Set<String>> entry : s.entrySet()) {
            l.add(entry.getKey());
            l.addAll(entry.getValue());
        }
        return l;
    }

    public void fpSwitchInLoop(Set<Integer> source) {
        List<Integer> dest = new ArrayList<Integer>();
        for (Integer s : source) {
            switch (s.intValue()) {
            case 0:
                dest.add(s);
                break;
            case 1:
                dest.remove(s);
                break;
            }
        }
    }

    public void fpAllocationInLoop(Map<String, String> source) {
        Map<String, List<String>> dest = new HashMap<String, List<String>>();

        for (Map.Entry<String, String> entry : source.entrySet()) {

            List<String> l = new ArrayList<String>();
            l.add(entry.getValue());
            dest.put(entry.getKey(), l);
        }
    }

    public List<String> fpUnknownSrcSize(BufferedReader br) throws IOException {
        List<String> l = new ArrayList<String>();
        String line;
        while ((line = br.readLine()) != null) {
            l.add(line);
        }

        return l;
    }

    public List<Exception> fpPSCInCatchBlock(List<String> src) {
        List<Exception> exceptions = new ArrayList<Exception>();

        for (String s : src) {
            try {
                s = s.substring(1000, 1001);

            } catch (IndexOutOfBoundsException e) {
                exceptions.add(e);
            }
        }

        List<Exception> exceptions2 = new ArrayList<Exception>();

        for (String s : src) {
            try {
                s = s.substring(1000, 1001);
                if (s == null)
                    return null;
            } catch (IndexOutOfBoundsException e) {
                exceptions2.add(e);
            }
        }

        return exceptions;
    }
}

@@ -5,16 +5,17 @@
 age ex;%0A
+%0A
 import j
@@ -69,37 +69,8 @@
 on;%0A
-import java.util.ArrayDeque;%0A
 impo
@@ -97,32 +97,8 @@
 st;%0A
-import java.util.Deque;%0A
 impo
@@ -238,16 +238,42 @@
 til.Set;
+%0Aimport java.util.TreeSet;
 %0A%0Apublic
@@ -377,38 +377,32 @@
 s = new HashSet%3C
-String
 %3E();%0A        for
@@ -589,30 +589,16 @@
 HashMap%3C
-String, String
 %3E();%0A   
@@ -829,22 +829,16 @@
 HashSet%3C
-String
 %3E();%0A   
@@ -1470,38 +1470,32 @@
 = new ArrayList%3C
-String
 %3E();%0A        ll.
@@ -1633,21 +1633,19 @@
         
-Deque
+Set
 %3CLong%3E a
@@ -1656,23 +1656,16 @@
 new 
-ArrayDeque%3CLong
+TreeSet%3C
 %3E();
@@ -1836,38 +1836,32 @@
 = new ArrayList%3C
-String
 %3E();%0A        for
@@ -2081,38 +2081,32 @@
 = new ArrayList%3C
-String
 %3E();%0A        for
@@ -2369,23 +2369,16 @@
 rayList%3C
-Integer
 %3E();%0A   
@@ -2461,16 +2461,20 @@
     
+    
 case 0:%0A
     
@@ -2469,16 +2469,20 @@
 case 0:%0A
+    
         
@@ -2541,16 +2541,20 @@
     
+    
 case 1:%0A
     
@@ -2549,16 +2549,20 @@
 case 1:%0A
+    
         
@@ -2757,36 +2757,16 @@
 HashMap%3C
-String, List%3CString%3E
 %3E();%0A%0A  
@@ -2867,38 +2867,32 @@
 = new ArrayList%3C
-String
 %3E();%0A           
@@ -3095,22 +3095,16 @@
 rayList%3C
-String
 %3E();%0A   
@@ -3343,33 +3343,24 @@
 w ArrayList%3C
-Exception
 %3E();%0A%0A      
@@ -3612,25 +3612,16 @@
 rayList%3C
-Exception
 %3E();%0A%0A  
@@ -3742,16 +3742,18 @@
 == null)
+ %7B
 %0A       
@@ -3774,24 +3774,42 @@
 eturn null;%0A
+                %7D%0A
             

fix bad fp test