Here you can find the source of areEqual(final Iterator ittyA, final Iterator ittyB)
Parameter | Description |
---|---|
ittyA | An iterator |
ittyB | An iterator |
public static boolean areEqual(final Iterator ittyA, final Iterator ittyB)
//package com.java2s; //License from project: Apache License import java.util.Iterator; public class Main { /**// w ww . java 2s . co m * Checks if the contents of the two iterators are equal and of the same length. * Equality is determined using == operator on the internal objects. * * @param ittyA An iterator * @param ittyB An iterator * @return Returns true if the two iterators contain the same objects and are of the same length */ public static boolean areEqual(final Iterator ittyA, final Iterator ittyB) { if (ittyA.hasNext() != ittyB.hasNext()) return false; while (ittyA.hasNext()) { if (!ittyB.hasNext()) return false; if (ittyA.next() != ittyB.next()) return false; } return true; } }