Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

desmoj
Class QueueListFifo  view QueueListFifo download QueueListFifo.java

java.lang.Object
  extended bydesmoj.QueueList
      extended bydesmoj.QueueListFifo
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener

public class QueueListFifo
extends QueueList
implements java.beans.PropertyChangeListener

Contains the implementation of a double linked list to represent queueing functionality. The entities are queued first according to their priority and second in first in first out order. The statistc data of the queue will be stored in a QueueBased object. The QueueListFifo has a reference to its QueueBased object. It uses the QueueLink class to build a list out of links with references to each element's predecessor, successor, the QueueBased object this QueueListFifo is associated to and of course, the Entity that is supposed to be enqueued here. This class needs a reference to a subclass of QueueBased to update the queue statistics. It is used in many kinds of queue implementations i.e. in classes Queue and ProcessQueue.

Version:
DESMO-J, Ver. 1.5 copyright (c) 2001 licensed under GNU GPL

Field Summary
private  java.lang.String abbreviation
          An abbreviation to identify the sort of queueing discipline (like FIFO or LIFO or ...)
private  QueueLink head
          The first link element of the list.
private  QueueLink tail
          The last link element of the list It is set to null in the constructor to indicate that the QueueListFifo is empty.
 
Fields inherited from class desmoj.QueueList
clientQ
 
Constructor Summary
QueueListFifo()
          Constructs an empty QueueListFifo with no reference to its client QueueBased.
 
Method Summary
protected  boolean checkProcess(SimProcess proc)
          Checks whether the process using the QueueList is a valid SimProcess.
(package private)  boolean contains(Entity e)
          Returns true if the given entity is contained in the list, false otherwise.
(package private)  Entity first()
          Returns the first entity stored in the list.
 java.lang.String getAbbreviation()
          Returns an abbreviation as a String to identify the sort of queueing discipline (like FIFO or LIFO or ...).
(package private)  void insert(Entity e)
          Adds a new entity to the QueueListFifo.
(package private)  boolean insertAfter(Entity e, Entity which)
          Inserts the given "e" after the position of "which" in the queuelistfifo.
(package private)  boolean insertBefore(Entity e, Entity which)
          Inserts the given "e" before the position of "which" in the queuelistfifo.
(package private)  boolean isEmpty()
          Returns true, if no elements are inside the QueueListFifo, false otherwise
(package private)  Entity last()
          Returns the last entity stored in the queuelistfifo.
(package private)  Entity pred(Entity e)
          Returns the predecessor to the given entity in the queuelistfifo.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method will be called every time the Stock (the number of available units) has changed.
(package private)  boolean remove(Entity e)
          Removes the given entity from the queuelistfifo.
(package private)  boolean removeFirst()
          Removes the first entity from this QueueListFifo and returns true if it was removed successfully.
(package private)  boolean removeLast()
          Removes the last entity from the QueueListFifo and returns true if it was removed successfully.
(package private)  void sendWarning(java.lang.String description, java.lang.String location, java.lang.String reason, java.lang.String prevention)
          Sends a warning to the error output by forwarding it to the associated queuebased's sendwarning method.
(package private)  Entity succ(Entity e)
          Returns the successor to the given entity in the queuelistfifo.
 java.lang.String toString()
          Returns a string representation of the queuelistfifo.
 
Methods inherited from class desmoj.QueueList
getQueueBased, setQueueBased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

head

private QueueLink head
The first link element of the list. It is set to null in the constructor to indicate that the QueueListFifo is empty.


tail

private QueueLink tail
The last link element of the list It is set to null in the constructor to indicate that the QueueListFifo is empty.


abbreviation

private java.lang.String abbreviation
An abbreviation to identify the sort of queueing discipline (like FIFO or LIFO or ...)

Constructor Detail

QueueListFifo

public QueueListFifo()
Constructs an empty QueueListFifo with no reference to its client QueueBased. This no-arg constructor is necessary to instantiate an object of this class by calling the java.lang.Class.newInstance() method. The reference to the QueueBased object making use of this queue-functionality must be provided later by calling the setQueueBased() method. The initial length is always zero.

Method Detail

checkProcess

protected boolean checkProcess(SimProcess proc)
Checks whether the process using the QueueList is a valid SimProcess.


contains

boolean contains(Entity e)
Returns true if the given entity is contained in the list, false otherwise.

Specified by:
contains in class QueueList

first

Entity first()
Returns the first entity stored in the list. If the queue is empty, null is returned.

Specified by:
first in class QueueList

getAbbreviation

public java.lang.String getAbbreviation()
Returns an abbreviation as a String to identify the sort of queueing discipline (like FIFO or LIFO or ...). Is used to display the queueing discipline in the report of the QueueBased objects.

Specified by:
getAbbreviation in class QueueList

insert

void insert(Entity e)
Adds a new entity to the QueueListFifo. Entities are inserted according to their priority in descending order. The highest priority Entity will always be first in the queue. Entities with same priority are inserted in FiFo order.

Specified by:
insert in class QueueList

insertAfter

boolean insertAfter(Entity e,
                    Entity which)
Inserts the given "e" after the position of "which" in the queuelistfifo. Returns true if "e" is inserted correctly after "which". If the list is empty or the referenced "which" is not contained, the "e" will not be inserted and false is returned.

Specified by:
insertAfter in class QueueList

insertBefore

boolean insertBefore(Entity e,
                     Entity which)
Inserts the given "e" before the position of "which" in the queuelistfifo. Returns true if "e" is inserted correctly after "which". If the list is empty or the referenced "which" is not contained, the "e" will not be inserted and false is returned.

Specified by:
insertBefore in class QueueList

isEmpty

boolean isEmpty()
Returns true, if no elements are inside the QueueListFifo, false otherwise

Specified by:
isEmpty in class QueueList

last

Entity last()
Returns the last entity stored in the queuelistfifo. If the queuelistfifo is empty, null is returned.

Specified by:
last in class QueueList

pred

Entity pred(Entity e)
Returns the predecessor to the given entity in the queuelistfifo. If there is no predecessor or no entity, null is returned.

Specified by:
pred in class QueueList

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method will be called every time the Stock (the number of available units) has changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

remove

boolean remove(Entity e)
Removes the given entity from the queuelistfifo. Checks if the given entity to be removed does apply to all restrictions on this operation. These are :
  • The given reference to an entity must not be null
  • This queuelistfifo must not be empty, otherwise there's nothing to remove
  • The entity's queuelink to the queues it is in must not be null
  • The entity's list of queues it is in must contain a queuelink referencing this queuelistfifo
If all these restrictions apply, true is returned and the entity is removed, otherwise false is the return value because the given entity could not be removed since one of the restrictions above was not met.

Specified by:
remove in class QueueList

removeFirst

boolean removeFirst()
Removes the first entity from this QueueListFifo and returns true if it was removed successfully. If the queuelistfifo is empty, false is returned.

Specified by:
removeFirst in class QueueList

removeLast

boolean removeLast()
Removes the last entity from the QueueListFifo and returns true if it was removed successfully. If the queuelistfifo is empty, false is returned.

Specified by:
removeLast in class QueueList

sendWarning

void sendWarning(java.lang.String description,
                 java.lang.String location,
                 java.lang.String reason,
                 java.lang.String prevention)
Sends a warning to the error output by forwarding it to the associated queuebased's sendwarning method. Warnings are sent only if the queuebased's flag for queue implementation warnings is set to true.

Specified by:
sendWarning in class QueueList

succ

Entity succ(Entity e)
Returns the successor to the given entity in the queuelistfifo. If there is no successor or no entity in the queuelistfifo, null is returned.

Specified by:
succ in class QueueList

toString

public java.lang.String toString()
Returns a string representation of the queuelistfifo. The string is built by concatenating all string representations of the contained entities, calling their toString() methods.

Specified by:
toString in class QueueList