Question: all in java DLL class import java.util.*; public class DLL implements Iterable { private DLLNode head, tail; public DLL() { head = tail = null;
all in java
DLL class
import java.util.*;
public class DLL
private DLLNode
public DLL() { head = tail = null; }
public boolean isEmpty() { return head == null; }
public void clear() { head = tail = null; }
public void addToHead(T el) { if (head != null) { head = new DLLNode
public void addToTail(T el) { if (tail != null) { tail = new DLLNode
public T deleteFromHead() { if (isEmpty()) { return null; } T el = head.info; if (head == tail) // if only one node on the list; { head = tail = null; } else { // if more than one node in the list; head = head.next; head.prev = null; } return el; }
public T deleteFromTail() { if (isEmpty()) { return null; } T el = tail.info; if (head == tail) // if only one node on the list; { head = tail = null; } else { // if more than one node in the list; tail = tail.prev; tail.next = null; } return el; }
public T delete(T el) { if (isEmpty()) { return null; } else if (head.info.equals(el)) { return deleteFromHead(); } else if (tail.info.equals(el)) { return deleteFromTail(); } else { DLLNode
public void printAll() { for (DLLNode
public T find(T el) { DLLNode
public T getFirst() { if (head != null) { return head.info; } else { return null; } }
public T getLast() { if (tail != null) { return tail.info; } else { return null; } }
public String toString() { String s = "["; for (DLLNode
public Iterator
private class DLLIterator implements Iterator
DLLNode
public boolean hasNext() { return tmp != null; }
public T next() { T info = tmp.info; tmp = tmp.next; return info; }
public void remove() { // not implemented } }
// node of generic doubly linked list class class DLLNode
public T info; public DLLNode
public DLLNode() { next = null; prev = null; }
public DLLNode(T el) { info = el; next = null; prev = null; }
public DLLNode(T el, DLLNode

CS 205 Lab 5 - Queue Objectives: Learn How to Implement Queue using Doubly Linked List Learn How to Use Queue Examples: 1. Class Array Queue shows how queue may be implemented using array (as discussed in the lecture). Class TestArray Queue shows how this class may be used to perform the following operations: Enqueue an element Dequeue an element and print it Get first element and print it Print all elements in the queue Clear the queue Quit . 2. Class LLQueue shows how queue may be implemented using java.util.LinkedList (as discussed in the lecture). Class TestLLQueue shows how to use this class. Tasks: 1. The given file DLL.java implements generic linked list as we saw in Lab03. (a). Use this class to implement a class, DLLQueue, that represents a queue for processing any types of values (generic queue). (b) Write a test class, TestDoubleQueue, that uses DLLQueue to allow a user to perform the same operations as TestLL Queue but using Double data objects. (c) Write a test class, TestStudentQueue, that allows a user to perform the same operations as in (b) above but using Student objects. CS 205 Lab 5 - Queue Objectives: Learn How to Implement Queue using Doubly Linked List Learn How to Use Queue Examples: 1. Class Array Queue shows how queue may be implemented using array (as discussed in the lecture). Class TestArray Queue shows how this class may be used to perform the following operations: Enqueue an element Dequeue an element and print it Get first element and print it Print all elements in the queue Clear the queue Quit . 2. Class LLQueue shows how queue may be implemented using java.util.LinkedList (as discussed in the lecture). Class TestLLQueue shows how to use this class. Tasks: 1. The given file DLL.java implements generic linked list as we saw in Lab03. (a). Use this class to implement a class, DLLQueue, that represents a queue for processing any types of values (generic queue). (b) Write a test class, TestDoubleQueue, that uses DLLQueue to allow a user to perform the same operations as TestLL Queue but using Double data objects. (c) Write a test class, TestStudentQueue, that allows a user to perform the same operations as in (b) above but using Student objects
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
