J-Sim v1.2.1-p7 API

drcl.util.queue
Class QueueImpl

java.lang.Object
  extended bydrcl.DrclObj
      extended bydrcl.util.queue.QueueImpl
All Implemented Interfaces:
java.lang.Cloneable, ObjectDuplicable, Queue, java.io.Serializable
Direct Known Subclasses:
BSQueue, CalendarQueue, CalendarQueue2, CalendarQueue3, FIFOQueue, SimpleQueue, TreeMapQueue, VariableSizeQueueImpl

public abstract class QueueImpl
extends DrclObj
implements Queue

Base class for implementing a queue.

See Also:
Serialized Form

Constructor Summary
QueueImpl()
           
 
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 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  void enqueue(double key_, java.lang.Object element_)
          Enqueues the element with the associated key.
 void enqueue(java.lang.Object element_)
          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 enqueueAt(int pos_, double key_, java.lang.Object element_)
          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.
abstract  java.util.Enumeration getElementEnumerator()
           
abstract  java.util.Enumeration getKeyEnumerator()
           
abstract  int getLength()
          Returns the current length 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.
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.
 void merge(Queue that_)
          Enqueues the elements in 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 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 length of the queue is smaller than (n+1).
 
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

QueueImpl

public QueueImpl()
Method Detail

reset

public abstract void reset()
Description copied from interface: Queue
Empties the queue.

Specified by:
reset in interface Queue

isEmpty

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

Specified by:
isEmpty in interface Queue

enqueue

public abstract void enqueue(double key_,
                             java.lang.Object element_)
Description copied from interface: 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.

Specified by:
enqueue in interface Queue
Parameters:
key_ - the associated key.
element_ - the element to be put in the queue.

enqueueAt

public boolean enqueueAt(int pos_,
                         double key_,
                         java.lang.Object element_)
Description copied from interface: 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 create a conflict to the above condition.

Specified by:
enqueueAt in interface Queue
Parameters:
pos_ - the position.
key_ - the associated key.
element_ - the element to be put in the queue.
Returns:
false if key and position create a conflict.

enqueueAfter

public boolean enqueueAfter(java.lang.Object previousElement_,
                            java.lang.Object element_)
Description copied from interface: Queue
Enqueues the element right after the previousElement_ element and associates the element with a key equal to the previous element's.

Specified by:
enqueueAfter in interface Queue
Parameters:
previousElement_ - the previous element.
element_ - the element to be put in the queue.
Returns:
false if previousElement_ does not appear.

merge

public void merge(Queue that_)
Description copied from interface: Queue
Enqueues the elements in that_ by the order of that_.dequeue().

Specified by:
merge in interface Queue

enqueue

public void enqueue(java.lang.Object element_)
Description copied from interface: 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.

Specified by:
enqueue in interface Queue

dequeue

public abstract java.lang.Object dequeue()
Description copied from interface: Queue
Dequeues and returns the element with the smallest key. If two keys are identical, then first-in-first-out.

Specified by:
dequeue in interface Queue
Returns:
the element with the smallest key, null if the queue is empty.

dequeue

public abstract java.lang.Object dequeue(double key_)
Description copied from interface: Queue
Dequeues and returns the first element with the key matched the argument.

Specified by:
dequeue in interface Queue
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_)
Description copied from interface: Queue
Removes the first element that equals() the argument.

Specified by:
remove in interface Queue
Returns:
the element found; null if no element is matched.

remove

public abstract java.lang.Object remove(double key_,
                                        java.lang.Object element_)
Description copied from interface: Queue
Removes the first element that has the same key and equals() the argument.

Specified by:
remove in interface Queue
Returns:
the element found; null if no element is matched.

removeAll

public abstract void removeAll(java.lang.Object element_)
Description copied from interface: Queue
Removes all the elements that equals() the argument.

Specified by:
removeAll in interface Queue

removeAll

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

Specified by:
removeAll in interface Queue

remove

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

Specified by:
remove in interface Queue

firstElement

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

Specified by:
firstElement in interface Queue

firstKey

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

Specified by:
firstKey in interface Queue

lastElement

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

Specified by:
lastElement in interface Queue

lastKey

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

Specified by:
lastKey in interface Queue

retrieveAt

public abstract java.lang.Object retrieveAt(int n_)
Description copied from interface: Queue
Returns the nth element in the queue, no dequeue is performed.

Specified by:
retrieveAt in interface Queue
Returns:
null if the current length of the queue is smaller than (n+1).

retrieveKeyAt

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

Specified by:
retrieveKeyAt in interface Queue

retrieveBy

public abstract java.lang.Object retrieveBy(double key_)
Description copied from interface: Queue
Returns the first element with the key matched to the argument. No dequeue is performed.

Specified by:
retrieveBy in interface Queue
Returns:
null if no match is found.

retrieveAll

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

Specified by:
retrieveAll in interface Queue

retrieveAll

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

Specified by:
retrieveAll in interface Queue

_retrieveAll

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

Specified by:
_retrieveAll in interface Queue

retrieveKey

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

Specified by:
retrieveKey in interface Queue

contains

public abstract boolean contains(java.lang.Object element_)
Description copied from interface: Queue
Returns true if the queue contains the element.

Specified by:
contains in interface Queue

containsKey

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

Specified by:
containsKey in interface Queue

keys

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

Specified by:
keys in interface Queue

getKeyEnumerator

public abstract java.util.Enumeration getKeyEnumerator()
Specified by:
getKeyEnumerator in interface Queue

getElementEnumerator

public abstract java.util.Enumeration getElementEnumerator()
Specified by:
getElementEnumerator in interface Queue

getLength

public abstract int getLength()
Description copied from interface: Queue
Returns the current length of the queue.

Specified by:
getLength in interface Queue

info

public java.lang.String info(java.lang.String prefix_,
                             boolean listElement_)
Description copied from interface: Queue
Prints the content of the queue.

Specified by:
info in interface Queue
Parameters:
prefix_ - prefix of each line when printing.

info

public java.lang.String info()
Description copied from interface: Queue
Prints the content of the queue.

Specified by:
info in interface Queue

info

public java.lang.String info(java.lang.String prefix_)
Description copied from interface: Queue
Prints the content of the queue.

Specified by:
info in interface Queue

oneline

public abstract java.lang.String oneline()
Description copied from interface: Queue
Prints the content of the queue in one line of string.

Specified by:
oneline in interface Queue

diag

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

Specified by:
diag in interface Queue

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().

Specified by:
duplicate in interface ObjectDuplicable
Overrides:
duplicate in class DrclObj

J-Sim v1.2.1-p7 API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~