1 package uk.co.jezuk.mango.algorithms;2 3 /**4 * The algorithm ForEach applies the function <code>fn</code> to5 * each element in the <code>iterator</code> sequence. 6 * @version $Id: ForEach.java 50 2002-06-11 15:21:40Z jez $7 */8 public class ForEach9 {10 static public void execute(java.util.Iterator iterator, uk.co.jezuk.mango.UnaryFunction fn)11 {12 if(iterator == null || fn == null)13 return;14 15 while(iterator.hasNext())16 fn.fn(iterator.next());17 } // execute18 19 //////////////////////////////////20 private ForEach() { }21 } // ForEach22