DRCL JavaSim API

drcl.util.queue
Class CalendarQueue

java.lang.Object
  |
  +--drcl.DrclObj
        |
        +--drcl.util.queue.Queue
              |
              +--drcl.util.queue.CalendarQueue
All Implemented Interfaces:
java.lang.Cloneable, ObjectDuplicable, java.io.Serializable

public class CalendarQueue
extends Queue

See Also:
Serialized Form

Constructor Summary
CalendarQueue()
           
 
Method Summary
 drcl.util.queue.CalendarQueue._Element _dequeue()
           
 Element[] _retrieveAll()
          Returns all the elements in the queue sorted in the ascending order of the key values and the order of time of enqueues.
 boolean contains(java.lang.Object o_)
          Returns true if the queue contains the element.
 boolean containsKey(double key_)
          Returns true if the queue contains the key.
 java.lang.Object dequeue()
          Dequeues and returns the element with the smallest key.
 java.lang.Object dequeue(double key_)
          Dequeues and returns the first element with the key matched the argument.
 java.lang.String diag(boolean listElement_)
          Prints out for diagnosis.
 boolean enqueue(double key_, java.lang.Object o_)
          Enqueues the element with the associated key.
 boolean enqueue(double key_, java.lang.Object o_, int size_)
          Enqueues the element with the associated key.
 boolean enqueue(java.lang.Object o_)
          Associates the element with the largest key in the queue and then enqueues the element.
 boolean enqueue(java.lang.Object o_, int size_)
          Associates the element with the largest key in the queue and then enqueues the element.
 boolean enqueueAfter(java.lang.Object previousElement_, java.lang.Object element_)
          Enqueues the element right after the previousElement_ element and associates the element with a key equal to the previous element's.
 boolean enqueueAfter(java.lang.Object previousElement_, java.lang.Object element_, int size_)
          Enqueues the element right after the previousElement_ element and associates the element with a key equal to the previous element's.
 boolean enqueueAt(int pos_, double key_, java.lang.Object element_, int size_)
          Enqueues the element at the position specified with the associated key.
 java.lang.Object firstElement()
          Returns the first element in the queue, no dequeue is performed.
 double firstKey()
          Returns the first key in the queue, no dequeue is performed.
 java.util.Enumeration getElementEnumerator()
           
 java.util.Enumeration getKeyEnumerator()
           
 int getLength()
          Returns the current length of the queue.
 int getMaxSize()
          Returns the maximum size of the queue.
 int getSize()
          Returns the current size of the queue.
 java.lang.String info()
          Prints the content of the queue.
 java.lang.String info(java.lang.String prefix_)
          Prints the content of the queue.
 boolean isEmpty()
          Returns true if the queue is empty.
 boolean isFull()
          Returns true if the queue is full.
 double[] keys()
          Returns all the keys in the queue.
 java.lang.Object lastElement()
          Returns the last element in the queue, no dequeue is performed.
 double lastKey()
          Returns the last key in the queue, no dequeue is performed.
 java.lang.String oneline()
          Prints the content of the queue in one line of string.
 java.lang.Object remove(double key_, java.lang.Object obj_)
          Removes the first element that has the same key and equals() the argument.
 java.lang.Object remove(int n_)
          Removes and returns the nth element in the queue.
 java.lang.Object remove(java.lang.Object obj_)
          Removes the first element that equals() the argument.
 void removeAll(double key_, java.lang.Object o_)
          Removes all the elements that match both the argument key and element.
 void removeAll(java.lang.Object o_)
          Removes all the elements that equals() the argument.
 void reset()
          Empties the queue.
 void resize(int newsize_)
           
 java.lang.Object[] retrieveAll()
          Returns all the elements in the queue sorted in the ascending order of the key values and the order of time of enqueues.
 java.lang.Object[] retrieveAll(double key_)
          Returns all the elements with the keys matched to the argument.
 java.lang.Object retrieveAt(int n_)
          Returns the nth element in the queue, no dequeue is performed.
 java.lang.Object retrieveBy(double key_)
          Returns the first element with the key matched to the argument.
 double retrieveKey(java.lang.Object o_)
          Returns the key of the first matched element in this queue, Double.NaN if no match is found.
 double retrieveKeyAt(int n_)
          Returns the nth key in the queue, Double.NaN if the current size of the queue is smaller than (n+1).
 void setMaxSize(int size_)
           
 void setMaxSize(int size_, boolean truncate_)
          Sets the maximum size of the queue.
 
Methods inherited from class drcl.util.queue.Queue
duplicate, enqueueAt, getAvailableSize, info, isFull, merge
 
Methods inherited from class drcl.DrclObj
clone, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CalendarQueue

public CalendarQueue()
Method Detail

enqueue

public boolean enqueue(double key_,
                       java.lang.Object o_)
Description copied from class: Queue
Enqueues the element with the associated key. The elements in queue are sorted in the ascending order of their associated keys. If same keys appear in the queue, the element is put right after the last element with the same key.
Overrides:
enqueue in class Queue
Following copied from class: drcl.util.queue.Queue
Parameters:
key_ - the associated key.
element_ - the element to be put in the queue.
Returns:
false if the queue is full.

dequeue

public java.lang.Object dequeue()
Description copied from class: Queue
Dequeues and returns the element with the smallest key. If two keys are identical, then first-in-first-out.
Overrides:
dequeue in class Queue
Following copied from class: drcl.util.queue.Queue
Returns:
the element with the smallest key, null if the queue is empty.

_dequeue

public drcl.util.queue.CalendarQueue._Element _dequeue()

firstKey

public double firstKey()
Description copied from class: Queue
Returns the first key in the queue, no dequeue is performed. Returns java.lang.Double.NaN if the queue is empty.
Overrides:
firstKey in class Queue

firstElement

public java.lang.Object firstElement()
Description copied from class: Queue
Returns the first element in the queue, no dequeue is performed. Returns null if the queue is empty.
Overrides:
firstElement in class Queue

resize

public void resize(int newsize_)

remove

public java.lang.Object remove(double key_,
                               java.lang.Object obj_)
Description copied from class: Queue
Removes the first element that has the same key and equals() the argument.
Overrides:
remove in class Queue
Following copied from class: drcl.util.queue.Queue
Returns:
the element found; null if no element is matched.

remove

public java.lang.Object remove(java.lang.Object obj_)
Description copied from class: Queue
Removes the first element that equals() the argument.
Overrides:
remove in class Queue
Following copied from class: drcl.util.queue.Queue
Returns:
the element found; null if no element is matched.

isEmpty

public boolean isEmpty()
Description copied from class: Queue
Returns true if the queue is empty.
Overrides:
isEmpty in class Queue

isFull

public boolean isFull()
Description copied from class: Queue
Returns true if the queue is full.
Overrides:
isFull in class Queue

setMaxSize

public void setMaxSize(int size_)

setMaxSize

public void setMaxSize(int size_,
                       boolean truncate_)
Description copied from class: Queue
Sets the maximum size of the queue. If truncate_ is set, then the size_th element, and the elements after, are removed from the queue.
Overrides:
setMaxSize in class Queue

getSize

public int getSize()
Description copied from class: Queue
Returns the current size of the queue.
Overrides:
getSize in class Queue

getLength

public int getLength()
Description copied from class: Queue
Returns the current length of the queue.
Overrides:
getLength in class Queue

getMaxSize

public int getMaxSize()
Description copied from class: Queue
Returns the maximum size of the queue.
Overrides:
getMaxSize in class Queue

keys

public double[] keys()
Description copied from class: Queue
Returns all the keys in the queue. Duplicate keys may appear.
Overrides:
keys in class Queue

retrieveAll

public java.lang.Object[] retrieveAll()
Description copied from class: Queue
Returns all the elements in the queue sorted in the ascending order of the key values and the order of time of enqueues.
Overrides:
retrieveAll in class Queue

reset

public void reset()
Description copied from class: Queue
Empties the queue.
Overrides:
reset in class Queue

info

public java.lang.String info(java.lang.String prefix_)
Prints the content of the queue.
Overrides:
info in class Queue
Parameters:
prefix_ - prefix of each line when printing.

info

public java.lang.String info()
Prints the content of the queue.
Overrides:
info in class Queue

oneline

public java.lang.String oneline()
Prints the content of the queue in one line of string.
Overrides:
oneline in class Queue

diag

public java.lang.String diag(boolean listElement_)
Description copied from class: Queue
Prints out for diagnosis. The base implementation invokes Queue.info().
Overrides:
diag in class Queue

getElementEnumerator

public java.util.Enumeration getElementEnumerator()
Overrides:
getElementEnumerator in class Queue

getKeyEnumerator

public java.util.Enumeration getKeyEnumerator()
Overrides:
getKeyEnumerator in class Queue

enqueue

public boolean enqueue(java.lang.Object o_,
                       int size_)
Description copied from class: Queue
Associates the element with the largest key in the queue and then enqueues the element. If the queue is originally empty, then key 0.0 is assigned.
Overrides:
enqueue in class Queue
Following copied from class: drcl.util.queue.Queue
Parameters:
size_ - size of the element.
Returns:
false if the queue is full.

enqueue

public boolean enqueue(double key_,
                       java.lang.Object o_,
                       int size_)
Description copied from class: Queue
Enqueues the element with the associated key. The elements in queue are sorted in the ascending order of their associated keys. If same keys appear in the queue, the element is put right after the last element with the same key.
Overrides:
enqueue in class Queue
Following copied from class: drcl.util.queue.Queue
Parameters:
key_ - the associated key.
element_ - the element to be put in the queue.
size_ - size of the element.
Returns:
false if the queue is full.

enqueueAt

public boolean enqueueAt(int pos_,
                         double key_,
                         java.lang.Object element_,
                         int size_)
Description copied from class: Queue
Enqueues the element at the position specified with the associated key. Note that the elements in queue are sorted in the ascending order of their associated keys. Enqueue fails if position and key conflict with each other by the above condition.
Overrides:
enqueueAt in class Queue
Following copied from class: drcl.util.queue.Queue
Parameters:
pos_ - the position.
key_ - the associated key.
element_ - the element to be put in the queue.
size_ - size of the element.
Returns:
false if the queue is full or key and position conflict with each other.

enqueueAfter

public boolean enqueueAfter(java.lang.Object previousElement_,
                            java.lang.Object element_,
                            int size_)
Description copied from class: Queue
Enqueues the element right after the previousElement_ element and associates the element with a key equal to the previous element's.
Overrides:
enqueueAfter in class Queue
Following copied from class: drcl.util.queue.Queue
Parameters:
previousElement_ - the previous element.
element_ - the element to be put in the queue.
size_ - size of the element.
Returns:
false if previousElement_ does not appear or the queue is full.

enqueueAfter

public boolean enqueueAfter(java.lang.Object previousElement_,
                            java.lang.Object element_)
Description copied from class: Queue
Enqueues the element right after the previousElement_ element and associates the element with a key equal to the previous element's.
Overrides:
enqueueAfter in class Queue
Following copied from class: drcl.util.queue.Queue
Parameters:
previousElement_ - the previous element.
element_ - the element to be put in the queue.
Returns:
false if previousElement_ does not appear or the queue is full.

enqueue

public boolean enqueue(java.lang.Object o_)
Description copied from class: Queue
Associates the element with the largest key in the queue and then enqueues the element. If the queue is originally empty, then key 0.0 is assigned.
Overrides:
enqueue in class Queue
Following copied from class: drcl.util.queue.Queue
Returns:
false if the queue is full.

retrieveAll

public java.lang.Object[] retrieveAll(double key_)
Description copied from class: Queue
Returns all the elements with the keys matched to the argument. No dequeue is performed.
Overrides:
retrieveAll in class Queue

retrieveKey

public double retrieveKey(java.lang.Object o_)
Description copied from class: Queue
Returns the key of the first matched element in this queue, Double.NaN if no match is found.
Overrides:
retrieveKey in class Queue

dequeue

public java.lang.Object dequeue(double key_)
Description copied from class: Queue
Dequeues and returns the first element with the key matched the argument.
Overrides:
dequeue in class Queue
Following copied from class: drcl.util.queue.Queue
Returns:
the element with the key matched the argument, null if no key is matched or the queue is empty.

retrieveBy

public java.lang.Object retrieveBy(double key_)
Description copied from class: Queue
Returns the first element with the key matched to the argument. No dequeue is performed. Returns null if no match is found.
Overrides:
retrieveBy in class Queue

removeAll

public void removeAll(java.lang.Object o_)
Description copied from class: Queue
Removes all the elements that equals() the argument.
Overrides:
removeAll in class Queue

removeAll

public void removeAll(double key_,
                      java.lang.Object o_)
Description copied from class: Queue
Removes all the elements that match both the argument key and element.
Overrides:
removeAll in class Queue

lastKey

public double lastKey()
Description copied from class: Queue
Returns the last key in the queue, no dequeue is performed. Returns java.lang.Double.NaN if the queue is empty.
Overrides:
lastKey in class Queue

lastElement

public java.lang.Object lastElement()
Description copied from class: Queue
Returns the last element in the queue, no dequeue is performed. Returns null if the queue is empty.
Overrides:
lastElement in class Queue

retrieveKeyAt

public double retrieveKeyAt(int n_)
Description copied from class: Queue
Returns the nth key in the queue, Double.NaN if the current size of the queue is smaller than (n+1).
Overrides:
retrieveKeyAt in class Queue

retrieveAt

public java.lang.Object retrieveAt(int n_)
Description copied from class: Queue
Returns the nth element in the queue, no dequeue is performed. Returns null if the current size of the queue is smaller than (n+1).
Overrides:
retrieveAt in class Queue

remove

public java.lang.Object remove(int n_)
Description copied from class: Queue
Removes and returns the nth element in the queue. Returns null if the current size of the queue is smaller than (n+1).
Overrides:
remove in class Queue

containsKey

public boolean containsKey(double key_)
Description copied from class: Queue
Returns true if the queue contains the key.
Overrides:
containsKey in class Queue

_retrieveAll

public Element[] _retrieveAll()
Description copied from class: Queue
Returns all the elements in the queue sorted in the ascending order of the key values and the order of time of enqueues.
Overrides:
_retrieveAll in class Queue

contains

public boolean contains(java.lang.Object o_)
Description copied from class: Queue
Returns true if the queue contains the element.
Overrides:
contains in class Queue

DRCL JavaSim API

Copyright © 2001 - DRCL, OSU     ~ Back to JavaSim Home ~