1 package uk.co.jezuk.mango.algorithms; 2 3 6 public class Partition 7 { 8 static public java.util.Collection execute(java.util.Iterator iterator, uk.co.jezuk.mango.Predicate test, java.util.Collection results) 9 { 10 if((iterator == null) || (test == null)) 11 return results; 12 13 while(iterator.hasNext()) 14 { 15 Object obj = iterator.next(); 16 if(test.test(obj)) 17 { 18 iterator.remove(); 19 if(results != null) 20 results.add(obj); 21 } } 24 return results; 25 } 27 private Partition() { } 28 } | Popular Tags |