[Clirr-devel] CVS: clirr/src/java/net/sf/clirr/framework CoIterator.java,1.2,1.3
Status: Alpha
Brought to you by:
lkuehne
From: <lk...@us...> - 2004-06-13 10:43:31
|
Update of /cvsroot/clirr/clirr/src/java/net/sf/clirr/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27831 Modified Files: CoIterator.java Log Message: Made CoIterator class final to tighten the API. Index: CoIterator.java =================================================================== RCS file: /cvsroot/clirr/clirr/src/java/net/sf/clirr/framework/CoIterator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CoIterator.java 13 Jun 2004 09:46:08 -0000 1.2 +++ CoIterator.java 13 Jun 2004 10:43:20 -0000 1.3 @@ -25,8 +25,8 @@ import java.util.NoSuchElementException; /** - * This is an iterator that walks a pair of collections, returning - * matching pairs from the set. + * This is an iterator that walks a pair of collections, returning + * matching pairs from the set. * <p> * When an element is present in the left set but there is no equal object * in the right set, the pair (leftobj, null) is returned. @@ -49,17 +49,17 @@ * @author Simon Kitching. */ -public class CoIterator +public final class CoIterator { private Object[] left; private Object[] right; - + private int leftIndex; private int rightIndex; - + private Object currLeft; private Object currRight; - + private Comparator comparator; /** @@ -76,7 +76,7 @@ this.comparator = comparator; this.left = left.toArray(); this.right = right.toArray(); - + Arrays.sort(this.left, comparator); Arrays.sort(this.right, comparator); } @@ -97,7 +97,7 @@ this.comparator = comparator; this.left = (Object[]) left.clone(); this.right = (Object[]) right.clone(); - + Arrays.sort(this.left, comparator); Arrays.sort(this.right, comparator); } @@ -109,7 +109,7 @@ { return (leftIndex < left.length) || (rightIndex < right.length); } - + /** * Moves this iterator object to refer to the next "pair" of objects. * <p> @@ -124,16 +124,16 @@ { boolean haveLeft = leftIndex < left.length; boolean haveRight = rightIndex < right.length; - + if (!haveLeft && !haveRight) { currLeft = null; currRight = null; throw new NoSuchElementException(); } - + int order; - + if (haveLeft && !haveRight) { order = -1; @@ -151,8 +151,8 @@ Comparable c1 = (Comparable) left[leftIndex]; order = c1.compareTo(right[rightIndex]); } - - if (order < 0) + + if (order < 0) { currLeft = left[leftIndex]; currRight = null; @@ -172,11 +172,11 @@ ++rightIndex; } } - + /** * Return an object from the "left" collection specified to this object's * constructor. When the iterator has selected an element in the "right" - * collection for which there is no corresponding element in the left + * collection for which there is no corresponding element in the left * collection, then this will return null. */ public Object getLeft() |