KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > uk > co > jezuk > mango > algorithms > ForEach


1 package uk.co.jezuk.mango.algorithms;
2
3 /**
4  * The algorithm ForEach applies the function <code>fn</code> to
5  * 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 ForEach
9 {
10     static public void execute(java.util.Iterator JavaDoc 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     } // execute
18

19     //////////////////////////////////
20
private ForEach() { }
21 } // ForEach
22
Popular Tags