Class Queue

java.lang.Object
  |
  +--Queue

public class Queue
extends java.lang.Object

File: Queue Class Description: This is my Queue class. Its members are Proc objects. Project: MAC-5755 Sistemas Operacionais Distribuídos Authors: Fábio Grezele (fg@ime.usp.br) Rachel de Paula(rpaula@ime.usp.br) Institution: Department of Computer Science University of Sao Paulo


Method Summary
 void dequeue()
          This method removes the process at the beginning of the queue.
 Proc dequeueLast()
          This method removes the process at the end of the queue.
 void enqueue(Proc newProcess)
          This method adds a new process to the queue.
 float getCreation()
          Reads the creationTime of the first process in the queue
 java.lang.String getName(int i)
          Reads the process name of the i-th process in the queue
 int getTime(int i)
          Reads the time left in the i-th process in the queue
 boolean isEmpty()
          returns TRUE if the queue is empty.
 boolean isFull()
          Returns TRUE if the queue is full.
 int length()
          Returns the number of processes currently in the queue.
 void rotate()
          This method rotates the queue, so that Queue[0] is always the element being serviced by the CPU.
 void setTime(int i, int time)
          Changes the time left for the process being served by the CPU which is always process 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isFull

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

isEmpty

public boolean isEmpty()
returns TRUE if the queue is empty.

length

public int length()
Returns the number of processes currently in the queue.

getTime

public int getTime(int i)
Reads the time left in the i-th process in the queue

getName

public java.lang.String getName(int i)
Reads the process name of the i-th process in the queue

getCreation

public float getCreation()
Reads the creationTime of the first process in the queue

setTime

public void setTime(int i,
                    int time)
Changes the time left for the process being served by the CPU which is always process 0.

enqueue

public void enqueue(Proc newProcess)
This method adds a new process to the queue. It receives as arguments the desired process execution time. Processes are always added to the end of the queue.

dequeue

public void dequeue()
This method removes the process at the beginning of the queue. All other processes are rotated towards the beginning of the queue.

dequeueLast

public Proc dequeueLast()
This method removes the process at the end of the queue.

rotate

public void rotate()
This method rotates the queue, so that Queue[0] is always the element being serviced by the CPU.