TreeSet "higher()" returns null when it shouldn't?

Viewed 67

I'm currently working on a project for which I use a TreeSet. The set is sorted based on a value. At some point in time, I want to get the right neighbour of a certain "key" value, which does exist and shows up in the debug with the correct values, yet the higher() method still returns null and I have no idea why.

Here is the test code and the debug-output.

//  Find the predecessor and successor
SemiCircle lower = status.lower(circle.getLeft());
SemiCircle higher = status.higher(circle.getRight());

The status is the TreeSet in this case. This is what it looks like upon searching for the lower and higher value:

SemiCircle{parent=0.3 0.8 0.2, isOnLeft=true, key=0.2826}          // This is circle.getLeft()
SemiCircle{parent=0.3 0.8 0.2, isOnLeft=false, key=0.3173}         // This is circle.getRight()
SemiCircle{parent=0.6 0.5 0.3, isOnLeft=true, key=0.3174}
SemiCircle{parent=0.6 0.5 0.3, isOnLeft=false, key=0.8825}

As you can see, lower should return null and higher should return the 3th semi-circle in the set, however it just returns null. Is there something I'm missing?

Edit: A SemiCircle is half a circle. It keeps the original circle, whether it is the left-half circle or the right and the "key" as explained above.

0 Answers
Related