File tree 1 file changed +5
-6
lines changed
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 7
7
* The elements that are added first are the first to be removed.
8
8
* New elements are added to the back/rear of the queue.
9
9
*
10
- * @author Unknown
11
10
*/
12
11
class Queue {
13
12
/**
@@ -53,7 +52,8 @@ public Queue(int size) {
53
52
public boolean insert (int x ) {
54
53
if (isFull ())
55
54
return false ;
56
- rear = (rear + 1 ) % maxSize ; // If the back of the queue is the end of the array wrap around to the front
55
+ // If the back of the queue is the end of the array wrap around to the front
56
+ rear = (rear + 1 ) % maxSize ;
57
57
queueArray [rear ] = x ;
58
58
nItems ++;
59
59
return true ;
@@ -64,9 +64,8 @@ public boolean insert(int x) {
64
64
*
65
65
* @return the new front of the queue
66
66
*/
67
- public int remove () { // Remove an element from the front of the queue
67
+ public int remove () {
68
68
if (isEmpty ()) {
69
- System .out .println ("Queue is empty" );
70
69
return -1 ;
71
70
}
72
71
int temp = queueArray [front ];
@@ -99,7 +98,7 @@ public int peekRear() {
99
98
* @return true if the queue is empty
100
99
*/
101
100
public boolean isEmpty () {
102
- return ( nItems == 0 ) ;
101
+ return nItems == 0 ;
103
102
}
104
103
105
104
/**
@@ -108,7 +107,7 @@ public boolean isEmpty() {
108
107
* @return true if the queue is full
109
108
*/
110
109
public boolean isFull () {
111
- return ( nItems == maxSize ) ;
110
+ return nItems == maxSize ;
112
111
}
113
112
114
113
/**
You can’t perform that action at this time.
0 commit comments