public SearchResult search ( Predicate < N > condition ) { int iteration = 0 ; Iterator < N > it = iterator ( ) ; long begin = System . currentTimeMillis ( ) ; N currentNode = null ; while ( it . hasNext ( ) ) { iteration ++ ; currentNode = it . next ( ) ; if ( condition . apply ( currentNode ) ) { break ; } } long end = System . currentTimeMillis ( ) ; return new SearchResult ( currentNode , iteration , end - begin ) ; }
Executes the search algorithm until the predicate condition is satisfied or there are no more nodes to explore .