All Packages Class Hierarchy This Package Previous Next Index
Class structure.QueueArray
java.lang.Object
|
+----structure.QueueArray
- public class QueueArray
- extends Object
- implements Queue
An implementation of a queue based on arrays.
QueueArray(int)
- Construct a queue holding at most size elements.
add(Object)
- Add a value to the tail of the queue.
clear()
- Remove all the values from the queue.
dequeue()
- Remove a value from the head of the queue.
enqueue(Object)
- Add a value to the tail of the queue.
isEmpty()
- Determine if the queue is empty.
isFull()
- Determines if the queue is not able to accept any new values.
peek()
- Fetch the value at the head of the queue.
remove()
- Remove a value from the head of the queue.
size()
- Determine the number of elements within the queue.
toString()
- Construct a string representation of the queue.
QueueArray
public QueueArray(int size)
- Construct a queue holding at most size elements.
- Postcondition:
- create a queue capable of holding at most size values.
- Parameters:
- size - The maximum size of the queue.
add
public void add(Object value)
- Add a value to the tail of the queue.
- Precondition:
- the queue is not full
- Postcondition:
- the value is added to the tail of the structure
- Parameters:
- value - The value added.
- See Also:
- enqueue
enqueue
public void enqueue(Object value)
- Add a value to the tail of the queue.
- Precondition:
- the queue is not full
- Postcondition:
- the value is added to the tail of the structure
- Parameters:
- value - The value to be added.
remove
public Object remove()
- Remove a value from the head of the queue.
- Precondition:
- the queue is not empty
- Postcondition:
- the head of the queue is removed and returned
- Returns:
- The value actually removed.
- See Also:
- dequeue
dequeue
public Object dequeue()
- Remove a value from the head of the queue.
- Precondition:
- the queue is not empty
- Postcondition:
- the head of the queue is removed and returned
- Returns:
- The value removed from the queue.
peek
public Object peek()
- Fetch the value at the head of the queue.
- Precondition:
- the queue is not empty
- Postcondition:
- the element at the head of the queue is returned
- Returns:
- Reference to the first value of the queue.
size
public int size()
- Determine the number of elements within the queue.
- Postcondition:
- returns the number of elements in the queue.
- Returns:
- The number of elements within the queue.
clear
public void clear()
- Remove all the values from the queue.
- Postcondition:
- removes all elements from the queue.
isFull
public boolean isFull()
- Determines if the queue is not able to accept any new values.
- Postcondition:
- returns true if the queue is at its capacity.
- Returns:
- True iff the queue is full.
isEmpty
public boolean isEmpty()
- Determine if the queue is empty.
- Postcondition:
- returns true iff the queue is empty
- Returns:
- True iff the queue is empty.
toString
public String toString()
- Construct a string representation of the queue.
- Postcondition:
- returns string representation of queue
- Returns:
- String representing the queue.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index