DRCL JavaSim API

drcl.util.queue
Class Queue

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

public abstract class Queue
extends DrclObj

See Also:
Serialized Form

Constructor Summary
Queue()
           
 
Method Summary
abstract  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.
abstract  boolean contains(java.lang.Object element_)
          Returns true if the queue contains the element.
abstract  boolean containsKey(double key_)
          Returns true if the queue contains the key.
abstract  java.lang.Object dequeue()
          Dequeues and returns the element with the smallest key.
abstract  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.
 void duplicate(java.lang.Object source_)
          opies the content of the source_ object to this object.
abstract  boolean enqueue(double key_, java.lang.Object element_)
          Enqueues the element with the associated key.
abstract  boolean enqueue(double key_, java.lang.Object element_, int size_)
          Enqueues the element with the associated key.
abstract  boolean enqueue(java.lang.Object element_)
          Associates the element with the largest key in the queue and then enqueues the element.
abstract  boolean enqueue(java.lang.Object element_, 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.
abstract  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_)
          Enqueues the element at the position specified with the associated key.
abstract  boolean enqueueAt(int pos_, double key_, java.lang.Object element_, int size_)
          Enqueues the element at the position specified with the associated key.
abstract  java.lang.Object firstElement()
          Returns the first element in the queue, no dequeue is performed.
abstract  double firstKey()
          Returns the first key in the queue, no dequeue is performed.
 int getAvailableSize()
          Returns the vacancy of the queue.
abstract  java.util.Enumeration getElementEnumerator()
           
abstract  java.util.Enumeration getKeyEnumerator()
           
abstract  int getLength()
          Returns the current length of the queue.
abstract  int getMaxSize()
          Returns the maximum size of the queue.
abstract  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.
 java.lang.String info(java.lang.String prefix_, boolean listElement_)
          Prints the content of the queue.
 boolean isEmpty()
          Returns true if the queue is empty.
 boolean isFull()
          Returns true if the queue is full.
 boolean isFull(int size_)
          Returns true if the queue will be overflowed by an object of the size.
abstract  double[] keys()
          Returns all the keys in the queue.
abstract  java.lang.Object lastElement()
          Returns the last element in the queue, no dequeue is performed.
abstract  double lastKey()
          Returns the last key in the queue, no dequeue is performed.
 boolean merge(Queue that_)
          Enqueues the elements in the queue that_ by the order of that_.dequeue().
abstract  java.lang.String oneline()
          Prints the content of the queue in one line of string.
abstract  java.lang.Object remove(double key_, java.lang.Object element_)
          Removes the first element that has the same key and equals() the argument.
abstract  java.lang.Object remove(int n_)
          Removes and returns the nth element in the queue.
abstract  java.lang.Object remove(java.lang.Object element_)
          Removes the first element that equals() the argument.
abstract  void removeAll(double key_, java.lang.Object element_)
          Removes all the elements that match both the argument key and element.
abstract  void removeAll(java.lang.Object element_)
          Removes all the elements that equals() the argument.
abstract  void reset()
          Empties the queue.
abstract  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.
abstract  java.lang.Object[] retrieveAll(double key_)
          Returns all the elements with the keys matched to the argument.
abstract  java.lang.Object retrieveAt(int n_)
          Returns the nth element in the queue, no dequeue is performed.
abstract  java.lang.Object retrieveBy(double key_)
          Returns the first element with the key matched to the argument.
abstract  double retrieveKey(java.lang.Object o_)
          Returns the key of the first matched element in this queue, Double.NaN if no match is found.
abstract  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).
abstract  void setMaxSize(int size_, boolean truncate_)
          Sets the maximum size of the queue.
 
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

Queue

public Queue()
Method Detail

reset

public abstract void reset()
Empties the queue.

isEmpty

public boolean isEmpty()
Returns true if the queue is empty.

isFull

public boolean isFull()
Returns true if the queue is full.

isFull

public boolean isFull(int size_)
Returns true if the queue will be overflowed by an object of the size.

enqueue

public abstract boolean enqueue(double key_,
                                java.lang.Object element_)
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.
Parameters:
key_ - the associated key.
element_ - the element to be put in the queue.
Returns:
false if the queue is full.

enqueueAt

public boolean enqueueAt(int pos_,
                         double key_,
                         java.lang.Object element_)
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.
Parameters:
pos_ - the position.
key_ - the associated key.
element_ - the element to be put in the queue.
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_)
Enqueues the element right after the previousElement_ element and associates the element with a key equal to the previous element's.
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 abstract boolean enqueue(double key_,
                                java.lang.Object element_,
                                int size_)
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.
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 abstract boolean enqueueAt(int pos_,
                                  double key_,
                                  java.lang.Object element_,
                                  int size_)
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.
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 abstract 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.
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.

merge

public boolean merge(Queue that_)
Enqueues the elements in the queue that_ by the order of that_.dequeue().
Returns:
false if not all the elements in that_ are successfully enqueued.

enqueue

public abstract boolean enqueue(java.lang.Object element_)
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.
Returns:
false if the queue is full.

enqueue

public abstract boolean enqueue(java.lang.Object element_,
                                int size_)
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.
Parameters:
size_ - size of the element.
Returns:
false if the queue is full.

dequeue

public abstract java.lang.Object dequeue()
Dequeues and returns the element with the smallest key. If two keys are identical, then first-in-first-out.
Returns:
the element with the smallest key, null if the queue is empty.

dequeue

public abstract java.lang.Object dequeue(double key_)
Dequeues and returns the first element with the key matched the argument.
Returns:
the element with the key matched the argument, null if no key is matched or the queue is empty.

remove

public abstract java.lang.Object remove(java.lang.Object element_)
Removes the first element that equals() the argument.
Returns:
the element found; null if no element is matched.

remove

public abstract java.lang.Object remove(double key_,
                                        java.lang.Object element_)
Removes the first element that has the same key and equals() the argument.
Returns:
the element found; null if no element is matched.

removeAll

public abstract void removeAll(java.lang.Object element_)
Removes all the elements that equals() the argument.

removeAll

public abstract void removeAll(double key_,
                               java.lang.Object element_)
Removes all the elements that match both the argument key and element.

remove

public abstract java.lang.Object remove(int n_)
Removes and returns the nth element in the queue. Returns null if the current size of the queue is smaller than (n+1).

firstElement

public abstract java.lang.Object firstElement()
Returns the first element in the queue, no dequeue is performed. Returns null if the queue is empty.

firstKey

public abstract double firstKey()
Returns the first key in the queue, no dequeue is performed. Returns java.lang.Double.NaN if the queue is empty.

lastElement

public abstract java.lang.Object lastElement()
Returns the last element in the queue, no dequeue is performed. Returns null if the queue is empty.

lastKey

public abstract double lastKey()
Returns the last key in the queue, no dequeue is performed. Returns java.lang.Double.NaN if the queue is empty.

retrieveAt

public abstract java.lang.Object retrieveAt(int n_)
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).

retrieveKeyAt

public abstract 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).

retrieveBy

public abstract java.lang.Object retrieveBy(double key_)
Returns the first element with the key matched to the argument. No dequeue is performed. Returns null if no match is found.

retrieveAll

public abstract java.lang.Object[] retrieveAll(double key_)
Returns all the elements with the keys matched to the argument. No dequeue is performed.

retrieveAll

public abstract 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.

_retrieveAll

public abstract 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.

retrieveKey

public abstract double retrieveKey(java.lang.Object o_)
Returns the key of the first matched element in this queue, Double.NaN if no match is found.

contains

public abstract boolean contains(java.lang.Object element_)
Returns true if the queue contains the element.

containsKey

public abstract boolean containsKey(double key_)
Returns true if the queue contains the key.

keys

public abstract double[] keys()
Returns all the keys in the queue. Duplicate keys may appear.

getKeyEnumerator

public abstract java.util.Enumeration getKeyEnumerator()

getElementEnumerator

public abstract java.util.Enumeration getElementEnumerator()

getSize

public abstract int getSize()
Returns the current size of the queue.

getLength

public abstract int getLength()
Returns the current length of the queue.

getMaxSize

public abstract int getMaxSize()
Returns the maximum size of the queue.

getAvailableSize

public int getAvailableSize()
Returns the vacancy of the queue.

setMaxSize

public abstract void setMaxSize(int size_,
                                boolean truncate_)
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.

info

public java.lang.String info(java.lang.String prefix_,
                             boolean listElement_)
Prints the content of the queue.
Parameters:
prefix_ - prefix of each line when printing.

info

public java.lang.String info()
Prints the content of the queue.

info

public java.lang.String info(java.lang.String prefix_)
Prints the content of the queue.

oneline

public abstract java.lang.String oneline()
Prints the content of the queue in one line of string.

diag

public java.lang.String diag(boolean listElement_)
Prints out for diagnosis. The base implementation invokes info().

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: DrclObj
opies the content of the source_ object to this object. he subclass must implement this method to realize DrclObj.clone().
Overrides:
duplicate in class DrclObj

DRCL JavaSim API

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