public boolean equals(int ignoreOwnElement,Sequence sequence,int ignoreItsElement){
  int ownIndex=0;
  int itsIndex=0;
  Iterator<Item> ownIterator=itemIterator();
  Iterator<Item> itsIterator=sequence.itemIterator();
  while (true) {
    if (ignoreOwnElement == ownIndex) {
      ownIterator.next();
      ownIndex++;
    }
    if (ignoreItsElement == itsIndex) {
      itsIterator.next();
      itsIndex++;
    }
    if (!ownIterator.hasNext() || !itsIterator.hasNext()) {
      if (!ownIterator.hasNext() && !itsIterator.hasNext()) {
        return true;
      }
      return false;
    }
    Item ownItem=ownIterator.next();
    Item itsItem=itsIterator.next();
    ownIndex++;
    itsIndex++;
    if (!ownItem.equals(itsItem)) {
      return false;
    }
  }
}

public boolean equals ( int ignoreOwnElement , Sequence sequence , int ignoreItsElement ) { int ownIndex = 0 ; int itsIndex = 0 ; Iterator < Item > ownIterator = itemIterator ( ) ; Iterator < Item > itsIterator = sequence . itemIterator ( ) ; while ( true ) { if ( ignoreOwnElement == ownIndex ) { ownIterator . next ( ) ; ownIndex ++ ; } if ( ignoreItsElement == itsIndex ) { itsIterator . next ( ) ; itsIndex ++ ; } if ( ! ownIterator . hasNext ( ) || ! itsIterator . hasNext ( ) ) { if ( ! ownIterator . hasNext ( ) && ! itsIterator . hasNext ( ) ) { return true ; } return false ; } Item ownItem = ownIterator . next ( ) ; Item itsItem = itsIterator . next ( ) ; ownIndex ++ ; itsIndex ++ ; if ( ! ownItem . equals ( itsItem ) ) { return false ; } } }
this method implements an enhanced equals method where the specified elements of the sequences are treated as if not existent . this avoids construction of new sequences .
