/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
private int getFence() { if (array == null) fence = (array = queue.toArray()).length; return fence; }
@SuppressWarnings("unchecked") public Object[] toArray(Object[] a) { return queue.toArray(a); }
private int getFence() { if (array == null) fence = (array = queue.toArray()).length; return fence; }
private int getFence() { if (array == null) fence = (array = queue.toArray()).length; return fence; }
public Object[] toArray() { return queue.toArray(); }
private int getFence() { if (array == null) fence = (array = queue.toArray()).length; return fence; }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
/** * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * * <p>The returned iterator is a "weakly consistent" iterator that * will never throw {@link java.util.ConcurrentModificationException * ConcurrentModificationException}, and guarantees to traverse * elements as they existed upon construction of the iterator, and * may (but is not guaranteed to) reflect any modifications * subsequent to construction. * * @return an iterator over the elements in this queue */ public Iterator<E> iterator() { return new Itr(toArray()); }
public void shutdown() { /* Remove any non-critical system tasks from the executor first */ for (final Runnable runnable : queue.toArray(new Runnable[0])) { if (((FutureTaskWrapper<?>)runnable).getPriorityCallable().getPriority().getPriority() != Priority.SYSTEM) { threadPoolExecutor.remove(runnable); } } threadPoolExecutor.shutdown(); }
/** * return all sequence numbers whose last feedback time is larger than k*RTT * * @param RTT - the current round trip time * @param doFeedback - true if the k parameter should be increased and the time should * be reset (using {@link ReceiverLossListEntry#feedback()} ) * @return */ public List<Long>getFilteredSequenceNumbers(long RTT, boolean doFeedback){ List<Long>result=new ArrayList<Long>(); ReceiverLossListEntry[]sorted=backingList.toArray(new ReceiverLossListEntry[0]); Arrays.sort(sorted); for(ReceiverLossListEntry e: sorted){ if( (Util.getCurrentTime()-e.getLastFeedbackTime())>e.getK()*RTT){ result.add(e.getSequenceNumber()); if(doFeedback)e.feedback(); } } return result; }
public class LimitedPBQ extends PriorityBlockingQueue { private int maxItems; public LimitedPBQ(int maxItems){ this.maxItems = maxItems; } @Override public boolean offer(Object e) { boolean success = super.offer(e); if(!success){ return false; } else if (this.size()>maxItems){ // Need to drop last item in queue // The array is not guaranteed to be in order, // so you should sort it to be sure, even though Sun's Java 6 // version will return it in order this.remove(this.toArray()[this.size()-1]); } return true; } }