I am looking for feedback on my Doubly Linked Listdoubly linked list implementation that I have written in Java. I am looking for specific feedback on the efficiency of my code, as well as my usage of generics. I am pretty new to using generics in Java, and I'm not quite sure that I am using them correctly yet.
My node class is pretty basic, but I'd like to revisit my Equals and Hashcode. Am I implementing these correctly? See snippet below:
My node class's equals/hashcode:
@Override
public boolean equals(Object that){
if(this == that)
return true;
if(!(that instanceof LLNode))
return false;
return this.data.equals(((LLNode)that).getData());
}
@Override
public int hashCode(){
return (this.data == null ? 0 : this.data.hashCode());
}
The DoublyLinkedListDoublyLinkedList
class, where the linked list is actually implemented can be found belowhere, as there is too much to post here I think. Am I missing any major functionality? Are generics used properly?
https://github.com/matt-y/DataStructures/blob/master/src/JavaDataStructures/DoublyLinkedList.java
If possible I'd also like to have my test cases reviewed to see if they are strong enough, and at least somewhat well designed. Those are here: https://github.com/matt-y/DataStructures/tree/master/test/JavaDataStructureshere.
I was unsure of how to test certain things - specifically cases where I am expecting exceptions to be thrown.