J-Sim v1.2.1-p7 API

drcl.util.queue
Class SimpleQueue

java.lang.Object
  extended bydrcl.DrclObj
      extended bydrcl.util.queue.QueueImpl
          extended bydrcl.util.queue.SimpleQueue
All Implemented Interfaces:
java.lang.Cloneable, ObjectDuplicable, Queue, java.io.Serializable
Direct Known Subclasses:
Stack

public class SimpleQueue
extends QueueImpl
implements java.io.Serializable

Queue with double type of keys. Although PriorityQueue implements Serializable, for the class to be it, the stored objects must be serializable also.

See Also:
Serialized Form

Constructor Summary
SimpleQueue()
           
 
Method Summary
 Element[] _retrieveAll()
          Returns all the elements in the queue sorted in the ascending order of the key values and the order of enqueues.
 boolean contains(java.lang.Object element_)
          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.
 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.
 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.
 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.
 void merge(Queue that_)
          Enqueues the elements in that_ by the order of that_.dequeue().
 java.lang.String oneline()
          Prints the content of the queue in one line of string.
 java.lang.Object remove(double key_, java.lang.Object element_)
          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 element_)
          Removes the first element that equals() the argument.
 void removeAll(double key_, java.lang.Object element_)
          Removes all the elements that match both the argument key and element.
 void removeAll(java.lang.Object element_)
          Removes all the elements that equals() the argument.
 void reset()
          Empties the queue.
 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.
 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 length of the queue is smaller than (n+1).
 
Methods inherited from class drcl.util.queue.QueueImpl
diag, duplicate, info, info, info, isEmpty
 
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

SimpleQueue

public SimpleQueue()
Method Detail

reset

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

Specified by:
reset in interface Queue
Specified by:
reset in class QueueImpl

enqueue

public 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
Specified by:
enqueue in class QueueImpl

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
Overrides:
enqueueAfter in class QueueImpl

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
Overrides:
enqueueAt in class QueueImpl

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
Overrides:
merge in class QueueImpl

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
Overrides:
enqueue in class QueueImpl

dequeue

public 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
Specified by:
dequeue in class QueueImpl

dequeue

public 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
Specified by:
dequeue in class QueueImpl

remove

public 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
Specified by:
remove in class QueueImpl

remove

public 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
Specified by:
remove in class QueueImpl

removeAll

public 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
Specified by:
removeAll in class QueueImpl

removeAll

public 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
Specified by:
removeAll in class QueueImpl

remove

public 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
Specified by:
remove in class QueueImpl

firstElement

public 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
Specified by:
firstElement in class QueueImpl

firstKey

public 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
Specified by:
firstKey in class QueueImpl

lastElement

public 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
Specified by:
lastElement in class QueueImpl

lastKey

public 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
Specified by:
lastKey in class QueueImpl

retrieveAt

public 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
Specified by:
retrieveAt in class QueueImpl

retrieveKeyAt

public 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
Specified by:
retrieveKeyAt in class QueueImpl

retrieveBy

public 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
Specified by:
retrieveBy in class QueueImpl

retrieveAll

public 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
Specified by:
retrieveAll in class QueueImpl

retrieveAll

public 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
Specified by:
retrieveAll in class QueueImpl

_retrieveAll

public 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
Specified by:
_retrieveAll in class QueueImpl

retrieveKey

public 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
Specified by:
retrieveKey in class QueueImpl

contains

public 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
Specified by:
contains in class QueueImpl

containsKey

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

Specified by:
containsKey in interface Queue
Specified by:
containsKey in class QueueImpl

keys

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

Specified by:
keys in interface Queue
Specified by:
keys in class QueueImpl

getKeyEnumerator

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

getElementEnumerator

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

getLength

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

Specified by:
getLength in interface Queue
Specified by:
getLength in class QueueImpl

oneline

public 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
Specified by:
oneline in class QueueImpl

J-Sim v1.2.1-p7 API

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