mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 06:23:08 +08:00
Remove unnecessary code (#4141)
This commit is contained in:
@ -17,21 +17,13 @@ public class CircularQueue {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
if (beginningOfQueue == -1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return beginningOfQueue == -1;
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
if (topOfQueue + 1 == beginningOfQueue) {
|
||||
return true;
|
||||
} else if (topOfQueue == size - 1 && beginningOfQueue == 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else return topOfQueue == size - 1 && beginningOfQueue == 0;
|
||||
}
|
||||
|
||||
public void enQueue(int value) {
|
||||
|
@ -91,13 +91,12 @@ public class Deques<T> {
|
||||
if (tail == null) {
|
||||
// If the deque is empty, add the node as the head and tail
|
||||
head = newNode;
|
||||
tail = newNode;
|
||||
} else {
|
||||
// If the deque is not empty, insert the node as the new tail
|
||||
newNode.prev = tail;
|
||||
tail.next = newNode;
|
||||
tail = newNode;
|
||||
}
|
||||
tail = newNode;
|
||||
|
||||
size++;
|
||||
}
|
||||
|
@ -177,6 +177,6 @@ public class Queues {
|
||||
|
||||
System.out.println(myQueue.peekFront()); // Will print 2
|
||||
System.out.println(myQueue.peekRear()); // Will print 7
|
||||
System.out.println(myQueue.toString()); // Will print [2, 5, 3, 7]
|
||||
System.out.println(myQueue); // Will print [2, 5, 3, 7]
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user