|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractQueue<DequeueEvent>
umontreal.iro.lecuyer.contactcenters.queue.WaitingQueue
umontreal.iro.lecuyer.contactcenters.queue.PriorityWaitingQueue
public final class PriorityWaitingQueue
Extends the WaitingQueue
class for a priority waiting queue. The
queue uses a SortedSet
to store the dequeue events, and the user can
supply a comparator indicating how to order pairs of elements. By default,
the sorted set is implemented using a red black tree [7] which is
a binary tree with automatic balancing for more stable search speed. This
class should be used only when there are many priorities in the system,
and queued contacts needs to be enumerated
in a consistent order. If
there are only a few degrees of priorities, it is more efficient to use one
standard waiting queue per priority.
If contacts do not have to be enumerated,
using a heap is more efficient.
Field Summary |
---|
Fields inherited from class umontreal.iro.lecuyer.contactcenters.queue.WaitingQueue |
---|
dqTypeRet |
Constructor Summary | |
---|---|
PriorityWaitingQueue()
Constructs a new waiting queue using a TreeSet to store
the elements. |
|
PriorityWaitingQueue(Comparator<? super DequeueEvent> comparator)
Constructs a new waiting queue using a TreeSet to store
the elements, and the given comparator to determine how to order
pairs of elements. |
|
PriorityWaitingQueue(SortedSet<DequeueEvent> set)
Constructs a new waiting queue using the given SortedSet
implementation to manage the elements. |
Method Summary | |
---|---|
Comparator<? super DequeueEvent> |
comparator()
Returns the comparator used to compare the dequeue events, or null if no comparator was given. |
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 |
---|
public PriorityWaitingQueue()
TreeSet
to store
the elements. Dequeue events are compared based on their associated
contacts, using DequeueEventComparator
.
public PriorityWaitingQueue(Comparator<? super DequeueEvent> comparator)
TreeSet
to store
the elements, and the given comparator to determine how to order
pairs of elements. The supplied comparator must be able to compare
DequeueEvent
objects.
comparator
- the comparator used to sort the elements.public PriorityWaitingQueue(SortedSet<DequeueEvent> set)
SortedSet
implementation to manage the elements. At any given time, this sorted set
contains only DequeueEvent
objects. If no comparator is given,
dequeue events are compared based on their associated contacts, using
Contact.compareTo(umontreal.iro.lecuyer.contactcenters.contact.Contact)
. The given set will be cleared before
it is used.
set
- a sorted set object that will contain the dequeue events.Method Detail |
---|
public Comparator<? super DequeueEvent> comparator()
SortedSet.comparator()
and returns the result.
protected Iterator<DequeueEvent> elementsIterator()
WaitingQueue
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.
elementsIterator
in class WaitingQueue
protected void elementsClear()
WaitingQueue
elementsClear
in class WaitingQueue
protected void elementsAdd(DequeueEvent dqEvent)
WaitingQueue
elementsAdd
in class WaitingQueue
dqEvent
- the dequeue event being added.protected boolean elementsIsEmpty()
WaitingQueue
elementsIsEmpty
in class WaitingQueue
protected DequeueEvent elementsGetFirst()
WaitingQueue
NoSuchElementException
if no such element exists.
elementsGetFirst
in class WaitingQueue
protected DequeueEvent elementsGetLast()
WaitingQueue
NoSuchElementException
if no such element exists.
elementsGetLast
in class WaitingQueue
protected DequeueEvent elementsRemoveFirst()
WaitingQueue
NoSuchElementException
if no such element
exists.
elementsRemoveFirst
in class WaitingQueue
protected DequeueEvent elementsRemoveLast()
WaitingQueue
NoSuchElementException
if no such element
exists.
elementsRemoveLast
in class WaitingQueue
public String toString()
toString
in class WaitingQueue
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |