Specification for a circular doubly linked list with a dummy

//Specification for a circular doubly linked list with a dummy header, list should be ordered

//node public class ListEmptyException public class NotInListException

public class DoublyLinkedList {

private class Node {

private T data;

private Node next;

private Node prev;

private Node (T d){}

private Node (T d, Node pref, Node nref){} }

private Node head;

private Node current;

private int size;

public DoublyLinkedList() public DoublyLinkedList (DoublyLinkedList l)

//insert\'s the new value into its proper ordered position in the list

public void insert (T d)

//removes an existing value from the list

public void remove (T d) throws ListEmptyException, NotInListException

//positions the list at the beginning of the list public void begin()

//advances to the next element in the list

public void advance()

//retreats to the previous item in the list

public void retreat()

//returns the value at the current point of the list

public T current() throws ListEmptyException

//determines if we are at the end of the list

public boolean end()

//determines if empty

public boolean isEmpty()

//returns the number of elements in the list

public int size() }

Solution

public class DblListnode {
  
private DblListnode prev;
private Object data;
private DblListnode next;

//*** methods ***
// 3 constructors
public DblListnode() {
   this(null, null, null);
}

public DblListnode(Object d) {
   this(null, d, null);
}

public DblListnode(DblListnode p, Object d, DblListnode n) {
prev = p;
   data = d;
   next = n;
}

// access to fields
public Object getData() {
return data;
}

public DblListnode getNext() {
return next;
}

public Object getPrev() {
return prev;
}

// modify fields
public void setData(Object ob) {
data = ob;
}

public void setNext(DblListnode n) {
next = n;
}

public void setPrev(DblListnode p) {
prev = p;
}
}

//Specification for a circular doubly linked list with a dummy header, list should be ordered //node public class ListEmptyException public class NotInListExcep
//Specification for a circular doubly linked list with a dummy header, list should be ordered //node public class ListEmptyException public class NotInListExcep

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site