Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Removes an item from the front of the queue, and returns its data */
- public Data dequeue() {
- if (isEmpty()) { // 1
- throw new NoSuchElementException("Queue is empty!"); // 1
- }
- Data data = head.data; // 2
- head = head.next; // 3
- size--; // 4
- if (isEmpty()) { // 5
- tail = null; // 5
- }
- return data; // 6
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement