[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections CollectionUtils.java
From: bayard () apache ! org
Date: 2001-11-26 17:15:33
[Download RAW message or body]
bayard 01/11/26 09:15:33
Modified: collections/src/java/org/apache/commons/collections
CollectionUtils.java
Log:
An empty iterator. It is immutable and always the same object instance.
Submitted by: Christopher Elkins <chrise@scardini.com>
Revision Changes Path
1.6 +30 -4 \
jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java
Index: CollectionUtils.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CollectionUtils.java 2001/08/29 16:10:29 1.5
+++ CollectionUtils.java 2001/11/26 17:15:33 1.6
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java,v \
1.5 2001/08/29 16:10:29 jstrachan Exp $
- * $Revision: 1.5 $
- * $Date: 2001/08/29 16:10:29 $
+ * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java,v \
1.6 2001/11/26 17:15:33 bayard Exp $ + * $Revision: 1.6 $
+ * $Date: 2001/11/26 17:15:33 $
*
* ====================================================================
*
@@ -77,10 +77,35 @@
*
* @author Rodney Waldhoff
*
- * @version $Id: CollectionUtils.java,v 1.5 2001/08/29 16:10:29 jstrachan Exp $
+ * @version $Id: CollectionUtils.java,v 1.6 2001/11/26 17:15:33 bayard Exp $
*/
public class CollectionUtils {
+
+ /**
+ * The empty iterator (immutable).
+ */
+ public static final Iterator EMPTY_ITERATOR = new EmptyIterator();
+
/**
+ * 'Hidden' class which acts as an EmptyIterator.
+ * An alternative is to use: Collections.EMPTY_LIST.iterator();
+ * however that will create a new iterator object each time.
+ */
+ private static class EmptyIterator implements Iterator {
+ public boolean hasNext() {
+ return false;
+ }
+
+ public Object next() {
+ throw new NoSuchElementException();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
* Returns a {@link Collection} containing the union
* of the given {@link Collection}s.
* <p>
@@ -502,6 +527,7 @@
return null;
}
}
+
/** Reverses the order of the given array */
public static void reverseArray(Object[] array) {
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic