nachos.kernel.threads
Class Queue

java.lang.Object
  extended by nachos.kernel.threads.Queue

public class Queue
extends java.lang.Object

Bounded-capacity queue.


Field Summary
(package private)  int C
          Maximum capacity of the queue.
(package private)  int first
          Index of the first element.
(package private)  int n
          Number of elements currently in the queue.
(package private)  int[] q
          Pointer to an array that holds the contents.
 
Constructor Summary
Queue()
           
 
Method Summary
 void insert(int value)
          Insert an integer at the end of the queue.
 boolean isEmpty()
          Return true iff the queue is empty.
 boolean isFull()
          Return true iff the queue is full.
 void Queue(int c)
          Initialize a list, empty to start with.
 int remove()
          Remove an integer from the front of the queue, returning its value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C

int C
Maximum capacity of the queue.


first

int first
Index of the first element.


n

int n
Number of elements currently in the queue.


q

int[] q
Pointer to an array that holds the contents.

Constructor Detail

Queue

public Queue()
Method Detail

Queue

public void Queue(int c)
Initialize a list, empty to start with. Elements can then be added to the list.

Parameters:
c - The capacity of the queue.

insert

public void insert(int value)
Insert an integer at the end of the queue. Abort on overflow (i.e., if the queue is full).

Parameters:
value - The value to insert

remove

public int remove()
Remove an integer from the front of the queue, returning its value. Abort on underflow (i.e., if the queue is empty).


isFull

public boolean isFull()
Return true iff the queue is full.


isEmpty

public boolean isEmpty()
Return true iff the queue is empty.