commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r751869 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java
Date Mon, 09 Mar 2009 22:10:01 GMT
Author: mbenson
Date: Mon Mar  9 22:10:00 2009
New Revision: 751869

URL: http://svn.apache.org/viewvc?rev=751869&view=rev
Log:
return type narrowing

Modified:
    commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java?rev=751869&r1=751868&r2=751869&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/ListOrderedSet.java
Mon Mar  9 22:10:00 2009
@@ -21,8 +21,10 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.ListIterator;
 import java.util.Set;
 
+import org.apache.commons.collections.OrderedIterator;
 import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
 import org.apache.commons.collections.list.UnmodifiableList;
 
@@ -171,8 +173,8 @@
         setOrder.clear();
     }
 
-    public Iterator<E> iterator() {
-        return new OrderedSetIterator<E>(setOrder.iterator(), collection);
+    public OrderedIterator<E> iterator() {
+        return new OrderedSetIterator<E>(setOrder.listIterator(), collection);
     }
 
     public boolean add(E object) {
@@ -279,14 +281,15 @@
     /**
      * Internal iterator handle remove.
      */
-    static class OrderedSetIterator<E> extends AbstractIteratorDecorator<E> {
+    static class OrderedSetIterator<E> extends AbstractIteratorDecorator<E> implements
OrderedIterator<E> {
 
         /** Object we iterate on */
         protected final Collection<E> set;
+
         /** Last object retrieved */
         protected E last;
 
-        private OrderedSetIterator(Iterator<E> iterator, Collection<E> set) {
+        private OrderedSetIterator(ListIterator<E> iterator, Collection<E> set)
{
             super(iterator);
             this.set = set;
         }
@@ -301,6 +304,15 @@
             iterator.remove();
             last = null;
         }
+
+        public boolean hasPrevious() {
+            return ((ListIterator<E>) iterator).hasPrevious();
+        }
+
+        public E previous() {
+            last = ((ListIterator<E>) iterator).previous();
+            return last;
+        }
     }
 
 }



Mime
View raw message