FindPositionIf.java :  » Development » mango » uk » co » jezuk » mango » algorithms » Java Open Source

Java Open Source » Development » mango 
mango » uk » co » jezuk » mango » algorithms » FindPositionIf.java
package uk.co.jezuk.mango.algorithms;

public class FindPositionIf
{
  static public int execute(java.util.Iterator iterator, uk.co.jezuk.mango.Predicate test)
  {
    if(iterator == null)
      return -1;

    int count = 0;
    while(iterator.hasNext())
    {
      Object obj = iterator.next();
      if(test.test(obj))
        return count;
      ++count;
    } // while ...
    
    return -1;
  } // execute

  private FindPositionIf() { }
} // Find
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.