We once again return to our list implementation. Your list is hopefully safe from external parties changing your previous
and next
references. (If your list contains any public Node<?> getNode()
methods, you should solve that first!)
For convenience, we want to build a version of our list that implements the Cloneable
interface.
Create a new descendant from your list that extends the original list, but also implements the Cloneable
interface.
Hint 1: This means that any content of the list should ALSO be cloneable. Hint 2: Although the doubly linked list has quite a tricky structure, creating a clone is a lot simpler than you may think.
After creating a clone of your list, you may want to actually test that you succeeded.
The test method assertEquals
uses the equals
method to confirm that two object instances have equivalent values.
Please use the assertNotSame
(this is the inverse of assertSame
) which confirms that although they are equal
they are not the very same reference!
So each element in the original list should be equal to each element in the clone, but they must not be the same object.