#101820: Return just the elements that were in the original collection versionability_89629_base_6
authorjtulach@netbeans.org
Tue, 15 May 2007 22:50:33 +0000
changeset 281a0e3d2f82b5b
parent 280 d3a1611fbb05
child 282 1ffaea4a2619
#101820: Return just the elements that were in the original collection
openide.util/src/org/openide/util/Utilities.java
openide.util/test/unit/src/org/openide/util/UtilitiesTopologicalSortTest.java
     1.1 --- a/openide.util/src/org/openide/util/Utilities.java	Fri May 04 16:28:15 2007 +0000
     1.2 +++ b/openide.util/src/org/openide/util/Utilities.java	Tue May 15 22:50:33 2007 +0000
     1.3 @@ -2250,6 +2250,9 @@
     1.4          }
     1.5  
     1.6          Collections.reverse(r);
     1.7 +        if (r.size() != c.size()) {
     1.8 +            r.retainAll(c);
     1.9 +        }
    1.10  
    1.11          return r;
    1.12      }
     2.1 --- a/openide.util/test/unit/src/org/openide/util/UtilitiesTopologicalSortTest.java	Fri May 04 16:28:15 2007 +0000
     2.2 +++ b/openide.util/test/unit/src/org/openide/util/UtilitiesTopologicalSortTest.java	Tue May 15 22:50:33 2007 +0000
     2.3 @@ -275,6 +275,19 @@
     2.4          
     2.5          List<Number> result = Utilities.topologicalSort(c, edges);
     2.6      }    
     2.7 +    
     2.8 +    public void testTopologicalSortIssue101820() throws Exception {
     2.9 +        Object a = "a";
    2.10 +        Object b = "b";
    2.11 +        
    2.12 +        Map<Object, Collection<Object>> deps = new HashMap<Object, Collection<Object>>();
    2.13 +        
    2.14 +        deps.put(a, Arrays.asList(b));
    2.15 +        deps.put(b, Arrays.asList());
    2.16 +        
    2.17 +        assertEquals(Arrays.asList(a), Utilities.topologicalSort(Arrays.asList(a), deps));
    2.18 +     }    
    2.19 +
    2.20      public void testErrorReporting () throws Exception {
    2.21          Collection c = Arrays.asList(new String[] {"a", "b", "c", "d", "e", "f"});
    2.22          Map m = new HashMap ();