A potential bug in equals implementation
lifove opened this issue · 2 comments
lifove commented
Hi
In a recent code, I've found a following suspicious code at src/com/jwetherell/algorithms/data_structures/DisjointSet.java
115 @Override
116 public boolean equals(Object o) {
117 if (!(o instanceof Item))
118 return false;
119
120 final Item<T> i = (Item<T>) o;
121 if ((i.parent!=null && parent!=null) && !(i.parent.value.equals(parent.value)))
122 return false;
123 if ((i.value!=null && value!=null) && !(value.equals(value)))
124 return false;
125 return true;
126 }
In Line 123, should !(value.equals(value) be !(i.value.equals(value)? This may not be an issue, but wanted to report just in case. Thanks!
phishman3579 commented
I think you are correct, thanks. You can fix it and send a merge request or I can fix it. Let me know.
lifove commented
OK, got it. I just sent a PR. Thanks!