src/share/classes/java/util/concurrent/DelayQueue.java

Print this page




 514             return cursor < array.length;
 515         }
 516 
 517         @SuppressWarnings("unchecked")
 518         public E next() {
 519             if (cursor >= array.length)
 520                 throw new NoSuchElementException();
 521             lastRet = cursor;
 522             return (E)array[cursor++];
 523         }
 524 
 525         public void remove() {
 526             if (lastRet < 0)
 527                 throw new IllegalStateException();
 528             Object x = array[lastRet];
 529             lastRet = -1;
 530             // Traverse underlying queue to find == element,
 531             // not just a .equals element.
 532             lock.lock();
 533             try {
 534                 for (Iterator it = q.iterator(); it.hasNext(); ) {
 535                     if (it.next() == x) {
 536                         it.remove();
 537                         return;
 538                     }
 539                 }
 540             } finally {
 541                 lock.unlock();
 542             }
 543         }
 544     }
 545 
 546 }


 514             return cursor < array.length;
 515         }
 516 
 517         @SuppressWarnings("unchecked")
 518         public E next() {
 519             if (cursor >= array.length)
 520                 throw new NoSuchElementException();
 521             lastRet = cursor;
 522             return (E)array[cursor++];
 523         }
 524 
 525         public void remove() {
 526             if (lastRet < 0)
 527                 throw new IllegalStateException();
 528             Object x = array[lastRet];
 529             lastRet = -1;
 530             // Traverse underlying queue to find == element,
 531             // not just a .equals element.
 532             lock.lock();
 533             try {
 534                 for (Iterator<E> it = q.iterator(); it.hasNext(); ) {
 535                     if (it.next() == x) {
 536                         it.remove();
 537                         return;
 538                     }
 539                 }
 540             } finally {
 541                 lock.unlock();
 542             }
 543         }
 544     }
 545 
 546 }