File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 77 * The elements that are added first are the first to be removed.
88 * New elements are added to the back/rear of the queue.
99 *
10- * @author Unknown
1110 */
1211class Queue {
1312 /**
@@ -53,7 +52,8 @@ public Queue(int size) {
5352 public boolean insert (int x ) {
5453 if (isFull ())
5554 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 ;
5757 queueArray [rear ] = x ;
5858 nItems ++;
5959 return true ;
@@ -64,9 +64,8 @@ public boolean insert(int x) {
6464 *
6565 * @return the new front of the queue
6666 */
67- public int remove () { // Remove an element from the front of the queue
67+ public int remove () {
6868 if (isEmpty ()) {
69- System .out .println ("Queue is empty" );
7069 return -1 ;
7170 }
7271 int temp = queueArray [front ];
@@ -99,7 +98,7 @@ public int peekRear() {
9998 * @return true if the queue is empty
10099 */
101100 public boolean isEmpty () {
102- return ( nItems == 0 ) ;
101+ return nItems == 0 ;
103102 }
104103
105104 /**
@@ -108,7 +107,7 @@ public boolean isEmpty() {
108107 * @return true if the queue is full
109108 */
110109 public boolean isFull () {
111- return ( nItems == maxSize ) ;
110+ return nItems == maxSize ;
112111 }
113112
114113 /**
You can’t perform that action at this time.
0 commit comments