Package edu.uiuc.ncsa.security.core.util
Class QueueWithSpare<E>
- java.lang.Object
- 
- edu.uiuc.ncsa.security.core.util.QueueWithSpare<E>
 
- 
- Direct Known Subclasses:
- KeyPairQueue
 
 public class QueueWithSpare<E> extends Object A Queue with a "spare tire". That is to say, the last entry returned by this queue is always stored in the spare. It is assumed that the queue is populated by another thread which might be lagging for expensive operations (such as key pair generation), so this is a queue that always has an element.Note about this and a JavaThe reason that this is a separate class from the java Queue is that the semantics are sufficiently different to invalidate its use: Since this queue always has an element, methods that return an exception when the queue is empty do not operate as expected. Moreover, having Queue inherit from Collection means there are many methods which must be over-ridden and do nothing but throw exceptions to make the semantics consistent with the contract of this class. Therefore, this is an independent class that inherits from nothing.QueueCreated by Jeff Gaynor 
 on 2/20/12 at 9:56 AM
- 
- 
Constructor SummaryConstructors Constructor Description QueueWithSpare()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()EgetSpare()booleanisEmpty()Slightly different than expected: This return true if there are no elements in the queue proper AND the spare is null.Epop()booleanpush(E e)Eremove()voidsetSpare(E spare)intsize()
 
- 
- 
- 
Method Detail- 
getSparepublic E getSpare() 
 - 
setSparepublic void setSpare(E spare) 
 - 
pushpublic boolean push(E e) 
 - 
poppublic E pop() 
 - 
removepublic E remove() 
 - 
sizepublic int size() 
 - 
isEmptypublic boolean isEmpty() Slightly different than expected: This return true if there are no elements in the queue proper AND the spare is null. Since the spare is not included in the calculation of the number of elements in the queue, usesize()== 0 to check if there are no elements in this queue.- Returns:
 
 - 
clearpublic void clear() 
 
- 
 
-