Question: I am working on implementing a doubly circular linkedlist using DLLNode. I may use some help for implementing doubly circular linkedlist. Help lol. here is
I am working on implementing a doubly circular linkedlist using DLLNode. I may use some help for implementing doubly circular linkedlist. Help lol.
here is DLLNode class
public class DLLNode
private DLLNode
private DLLNode
private T info;
public DLLNode(T info) {
this.info = info;
this.back = null;
this.forward = null;
}
public void setInfo(T info)
// Sets info of this LLNode.
{
this.info = info;
}
public T getInfo()
// Returns info of this LLONode.
{
return info;
}
public void setBack(DLLNode
// Sets back link of this DLLNode.
{
this.back = back;
}
public DLLNode
// Returns back link of this DLLNode.
{
return back;
}
public void setForward(DLLNode
// Sets forward link of this DLLNode;
{
this.forward = forward;
}
public DLLNode
// Returns forward link of this DLLNode.
{
return forward;
}
}
And here are methods to be implemented, name of class doesn't matter. This class implements the
int size();
// Returns the number of elements on this list.
void add(T element);
// Adds element to this list.
boolean remove (T element);
// Removes an element e from this list such that e.equals(element)
// and returns true; if no such element exists, returns false.
boolean contains (T element);
// Returns true if this list contains an element e such that
// e.equals(element); otherwise, returns false.
T get(T element);
// Returns an element e from this list such that e.equals(element);
// if no such element exists, returns null.
String toString();
// Returns a nicely formatted string that represents this list.
void reset();
// Initializes current position for an iteration through this list,
// to the first element on this list.
T getNext();
// Preconditions: The list is not empty
// The list has been reset
// The list has not been modified since the most recent reset
//
// Returns the element at the current position on this list.
// If the current position is the last element, then it advances the value
// of the current position to the first element; otherwise, it advances
// the value of the current position to the next element.
/**
T getPrevious();
* Returns the element at the current position on this list.
* If the current position is the first element, then it advances the value
* of the current position to the last element; otherwise, it advances
* the value of the current position to the previous element.
*
* @return the info of type T
*/
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
