Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.contactcenters.queue
Class PriorityWaitingQueue

    java.lang.Object
      java.util.AbstractCollection<E>
          java.util.AbstractQueue<DequeueEvent>
              umontreal.iro.lecuyer.contactcenters.queue.WaitingQueue
                  umontreal.iro.lecuyer.contactcenters.queue.PriorityWaitingQueue

All Implemented Interfaces:
  Iterable<DequeueEvent>, Collection<DequeueEvent>, Queue<DequeueEvent>, Initializable, Named

    public final class PriorityWaitingQueue

extends WaitingQueue

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

### PriorityWaitingQueue

    public PriorityWaitingQueue()

  Constructs a new waiting queue using a `TreeSet` to store the elements. Dequeue events are compared based on their associated contacts, using `DequeueEventComparator`.

### PriorityWaitingQueue

    public 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. The supplied comparator must be able to compare `DequeueEvent` objects.

  Parameters:
    `comparator` - the comparator used to sort the elements.

### PriorityWaitingQueue

    public PriorityWaitingQueue(SortedSet<DequeueEvent> set)

  Constructs a new waiting queue using the given `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.

  Parameters:
    `set` - a sorted set object that will contain the dequeue events.

Method Detail

### comparator

    public Comparator<? super DequeueEvent> comparator()

  Returns the comparator used to compare the dequeue events, or `null` if no comparator was given. This method calls `SortedSet.comparator()` and returns the result.

  Returns:
    the associated comparator or `null`.

### 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.

### 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`

### 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`

Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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