public static boolean equal ( Iterator itr1 , Iterator itr2 ) { if ( itr1 == null || itr2 == null ) { return false ; } else { while ( itr1 . hasNext ( ) && itr2 . hasNext ( ) ) { Object i = itr1 . next ( ) ; Object i2 = itr2 . next ( ) ; if ( ( i == null && i2 != null ) || ! ( i . equals ( i2 ) ) ) { return false ; } } if ( itr1 . hasNext ( ) || itr2 . hasNext ( ) ) { return false ; } return true ; } }
Tests two iterators for equality meaning that they have the same elements enumerated in the same order .