forked from MissMeriel/ShoppingCenterSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueInterface.java
More file actions
42 lines (33 loc) · 1.45 KB
/
QueueInterface.java
File metadata and controls
42 lines (33 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package master1;
public interface QueueInterface<T> {
public boolean isEmpty();
// Determines whether a queue is empty.
// Precondition: None.
// Postcondition: Returns true if the queue is empty;
// otherwise returns false.
public void enqueue(T newItem) throws QueueException;
// Adds an item at the back of a queue.
// Precondition: newItem is the item to be inserted.
// Postcondition: If the operation was successful, newItem
// is at the back of the queue. Some implementations
// may throw QueueException if newItem cannot be added
// to the queue.
public T dequeue() throws QueueException;
// Retrieves and removes the front of a queue.
// Precondition: None.
// Postcondition: If the queue is not empty, the item that
// was added to the queue earliest is removed. If the queue is
// empty, the operation is impossible and QueueException is thrown.
public void dequeueAll();
// Removes all items of a queue.
// Precondition: None.
// Postcondition: The queue is empty.
public T peek() throws QueueException;
// Retrieves the item at the front of a queue.
// Precondition: None.
// Postcondition: If the queue is not empty, the item
// that was added to the queue earliest is returned.
// If the queue is empty, the operation is impossible
// and QueueException is thrown.
public String toString();
} // end QueueInterface