1 22 package org.jboss.util.collection; 23 24 import java.util.Iterator ; 25 import java.util.List ; 26 import java.util.NoSuchElementException ; 27 28 34 public class ReverseListIterator 35 implements Iterator 36 { 37 38 protected final List list; 39 40 41 protected int current; 42 43 48 public ReverseListIterator(final List list) { 49 this.list = list; 50 current = list.size() - 1; 51 } 52 53 58 public boolean hasNext() { 59 return current > 0; 60 } 61 62 69 public Object next() { 70 if (current <= 0) { 71 throw new NoSuchElementException (); 72 } 73 74 return list.get(current--); 75 } 76 77 80 public void remove() { 81 list.remove(current); 82 } 83 } 84 | Popular Tags |