Skip to content

Commit 5147a24

Browse files
author
phishman3579
committed
Changed equals() to compareTo() in Skip List.
git-svn-id: https://java-algorithms-implementation.googlecode.com/svn/trunk@426 032fbc0f-8cab-eb90-e552-f08422b9a96a
1 parent b2ddb52 commit 5147a24

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/com/jwetherell/algorithms/data_structures/SkipList.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public boolean add(T value) {
9696
private NodeLevelPair<T> findPredecessor(T value) {
9797
Node<T> node = head;
9898
if (node==null) return null;
99-
if (node.value.equals(value)) return null;
99+
if (node.value.compareTo(value)==0) return null;
100100

101101
// Current node is not the node we are looking for; Keep moving down
102102
// until you find a node with a non-null "next" pointer.
@@ -283,7 +283,7 @@ public String getString(T value, int level) {
283283
builder.append("[").append(i).append("] ");
284284
node = head;
285285
while (node != null) {
286-
if (level==i && value!=null && node.value.equals(value))
286+
if (level==i && value!=null && node.value.compareTo(value)==0)
287287
builder.append("(").append(node.value).append(")");
288288
else
289289
builder.append(node.value);

0 commit comments

Comments
 (0)