1 14 15 package org.apache.activemq.kaha.impl.container; 16 17 import java.util.Iterator ; 18 import org.apache.activemq.kaha.impl.index.IndexItem; 19 import org.apache.activemq.kaha.impl.index.IndexLinkedList; 20 21 26 public class ContainerValueCollectionIterator implements Iterator { 27 28 protected BaseContainerImpl container; 29 protected IndexLinkedList list; 30 protected IndexItem nextItem; 31 protected IndexItem currentItem; 32 33 ContainerValueCollectionIterator(BaseContainerImpl container,IndexLinkedList list,IndexItem start){ 34 this.container=container; 35 this.list=list; 36 this.currentItem=start; 37 this.nextItem=list.getNextEntry((IndexItem)list.refreshEntry(start)); 38 } 39 40 public boolean hasNext(){ 41 return nextItem!=null; 42 } 43 44 public Object next(){ 45 synchronized(container){ 46 nextItem=(IndexItem)list.refreshEntry(nextItem); 47 currentItem=nextItem; 48 Object result=container.getValue(nextItem); 49 nextItem=list.getNextEntry(nextItem); 50 return result; 51 } 52 } 53 54 public void remove(){ 55 synchronized(container){ 56 if(currentItem!=null){ 57 currentItem=(IndexItem)list.refreshEntry(currentItem); 58 container.remove(currentItem); 59 } 60 } 61 } 62 } 63 | Popular Tags |