ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.queue
Class StandardWaitingQueue

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<DequeueEvent>
          extended by umontreal.iro.lecuyer.contactcenters.queue.WaitingQueue
              extended by umontreal.iro.lecuyer.contactcenters.queue.StandardWaitingQueue
All Implemented Interfaces:
Iterable<DequeueEvent>, Collection<DequeueEvent>, Queue<DequeueEvent>, Initializable, Named

public final class StandardWaitingQueue
extends WaitingQueue

Extends the WaitingQueue class for a standard waiting queue, without priority. The queue uses a List to store the dequeue events ordered by insertion times. By default, a doubly-linked list is used, which implements insertion and removal of the first and last elements in constant time.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.contactcenters.queue.WaitingQueue
dqTypeRet
 
Constructor Summary
StandardWaitingQueue()
          Constructs a new waiting queue using a LinkedList to store the elements.
StandardWaitingQueue(List<DequeueEvent> list)
          Constructs a new waiting queue using the given List implementation to manage the elements.
 
Method Summary
protected  void elementsAdd(DequeueEvent dqEvent)
          Adds the new dequeued event dqEvent to the internal data structure representing the waiting queue.
protected  void elementsClear()
          Clears all elements in the data structure representing the queued contacts.
protected  DequeueEvent elementsGetFirst()
          Returns the first element of the waiting queue's internal data structure, or throws a NoSuchElementException if no such element exists.
protected  DequeueEvent elementsGetLast()
          Returns the last element of the waiting queue's internal data structure, or throws a NoSuchElementException if no such element exists.
protected  boolean elementsIsEmpty()
          Determines if the internal waiting queue data structure is empty.
protected  Iterator<DequeueEvent> elementsIterator()
          Returns an iterator capable of traversing, in the correct order, the elements in the waiting queue's internal data structure.
protected  DequeueEvent elementsRemoveFirst()
          Removes and returns the first element in the waiting queue's internal data structure.
protected  DequeueEvent elementsRemoveLast()
          Removes and returns the last element in the waiting queue's internal data structure.
 String toString()
           
 
Methods inherited from class umontreal.iro.lecuyer.contactcenters.queue.WaitingQueue
add, add, addFromOldEvent, addWaitingQueueListener, clear, clear, clearWaitingQueueListeners, getAttributes, getDefaultDequeueType, getDequeueEvent, getFirst, getId, getLast, getMaximalQueueTime, getMaximalQueueTimeGenerator, getName, getWaitingQueueListeners, init, isEmpty, iterator, iterator, notifyDequeued, notifyEnqueued, notifyInit, offer, peek, poll, remove, remove, remove, removeFirst, removeLast, removeWaitingQueueListener, restore, save, setDefaultDequeueType, setId, setMaximalQueueTimeGenerator, setName, size, size
 
Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

StandardWaitingQueue

public StandardWaitingQueue()
Constructs a new waiting queue using a LinkedList to store the elements.


StandardWaitingQueue

public StandardWaitingQueue(List<DequeueEvent> list)
Constructs a new waiting queue using the given List implementation to manage the elements. This list must contain only DequeueEvent objects and it will be cleared before being used.

Parameters:
list - the list containing the queued contacts.
Method Detail

elementsClear

protected void elementsClear()
Description copied from class: WaitingQueue
Clears all elements in the data structure representing the queued contacts.

Specified by:
elementsClear in class WaitingQueue

elementsIterator

protected Iterator<DequeueEvent> elementsIterator()
Description copied from class: WaitingQueue
Returns an iterator capable of traversing, in the correct order, the elements in the waiting queue's internal data structure. This is different from the WaitingQueue.iterator(int) method because this iterator returns the contacts marked for dequeue as well as the contacts still enqueued. If the returned iterator does not implement remove(), WaitingQueue.remove(Contact,int) and WaitingQueue.getDequeueEvent(Contact) will not work properly.

Specified by:
elementsIterator in class WaitingQueue
Returns:
an iterator for the waiting queue elements.

elementsAdd

protected void elementsAdd(DequeueEvent dqEvent)
Description copied from class: WaitingQueue
Adds the new dequeued event dqEvent to the internal data structure representing the waiting queue.

Specified by:
elementsAdd in class WaitingQueue
Parameters:
dqEvent - the dequeue event being added.

elementsIsEmpty

protected boolean elementsIsEmpty()
Description copied from class: WaitingQueue
Determines if the internal waiting queue data structure is empty.

Specified by:
elementsIsEmpty in class WaitingQueue
Returns:
true if the data structure is empty, false otherwise.

elementsGetFirst

protected DequeueEvent elementsGetFirst()
Description copied from class: WaitingQueue
Returns the first element of the waiting queue's internal data structure, or throws a NoSuchElementException if no such element exists.

Specified by:
elementsGetFirst in class WaitingQueue
Returns:
the first element of the data structure.

elementsGetLast

protected DequeueEvent elementsGetLast()
Description copied from class: WaitingQueue
Returns the last element of the waiting queue's internal data structure, or throws a NoSuchElementException if no such element exists.

Specified by:
elementsGetLast in class WaitingQueue
Returns:
the last element of the data structure.

elementsRemoveFirst

protected DequeueEvent elementsRemoveFirst()
Description copied from class: WaitingQueue
Removes and returns the first element in the waiting queue's internal data structure. Throws a NoSuchElementException if no such element exists.

Specified by:
elementsRemoveFirst in class WaitingQueue
Returns:
the removed element.

elementsRemoveLast

protected DequeueEvent elementsRemoveLast()
Description copied from class: WaitingQueue
Removes and returns the last element in the waiting queue's internal data structure. Throws a NoSuchElementException if no such element exists.

Specified by:
elementsRemoveLast in class WaitingQueue
Returns:
the removed element.

toString

public String toString()
Overrides:
toString in class WaitingQueue

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.