Skip to main content
edited tags
Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
added 18 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

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.

I am looking for feedback on my Doubly 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 DoublyLinkedList class, where the linked list is actually implemented can be found below, 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/JavaDataStructures

I was unsure of how to test certain things - specifically cases where I am expecting exceptions to be thrown.

I am looking for feedback on my doubly 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 DoublyLinkedList class, where the linked list is actually implemented can be found here, as there is too much to post here I think. Am I missing any major functionality? Are generics used properly?

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.

I was unsure of how to test certain things - specifically cases where I am expecting exceptions to be thrown.

Codereview not necessary in title
Link
Caridorc
  • 27.6k
  • 7
  • 54
  • 135

Please Review my Generic Linked List Implementation in Java

Tweeted twitter.com/#!/StackCodeReview/status/161002361991598080
Source Link
mabufo
  • 301
  • 2
  • 6
Loading