| 1 19 20 package soot.util.queue; 21 import java.util.*; 22 23 31 public class QueueReader implements java.util.Iterator  32 { 33 private Object [] q; 34 private int index; 35 QueueReader( Object [] q, int index ) { 36 this.q = q; 37 this.index = index; 38 } 39 41 public final Object next() { 42 if( q[index] == null ) throw new NoSuchElementException(); 43 if( index == q.length - 1 ) { 44 q = (Object []) q[index]; 45 index = 0; 46 if( q[index] == null ) throw new NoSuchElementException(); 47 } 48 Object ret = q[index]; 49 if( ret == ChunkedQueue.NULL_CONST ) ret = null; 50 index++; 51 return ret; 52 } 53 54 55 public final boolean hasNext() { 56 if (q[index] == null) return false; 57 if (index == q.length - 1) { 58 q = (Object []) q[index]; 59 index = 0; 60 if (q[index] == null) return false; 61 } 62 return true; 63 } 64 65 public final void remove() { 66 throw new UnsupportedOperationException (); 67 } 68 69 public final Object clone() { 70 return new QueueReader( q, index ); 71 } 72 } 73 74 75 | Popular Tags |