java - TreeSet contains returns false, when definitely contains item -
I have an implementation of a line based on the pendet, I often use the treeset to change the sequence of items often.
Unfortunately I'm running into a bit of a problem, my queue range applies one (next), removes the () and () method (to remove TreeSet) in it ( ) And contains () and a basic iterative that returns the first item, but does not delete it).
I have a custom comparator that I use to sort the tree (below). If I am inside queue.remove (queue.next ()) in a synchronized block (thread safe), the length of the queue does not change.
If I do queue.contains (queue.next ()) then returns it false.
How is this possible? Items in the queue override the equals and hashed method, but as I understand, tree seals do not use all those methods.
t1.getName () below always returns a unique string (I apply the Private Class BayesianComparator Comparator & lt; SolverRunnable & gt; {@Override public int comparison (SolverRunnable T, SolverRunnable t1) {int s = Score (T1) - Score (Score: 1) T); If (s == 0) {return t 1.getName (). Compare (T.GetNanam ()); } Return S; } Public Int Score (Solar Rooney T) {Double Score = 0; (Node n: t.getModifiers (). KeySet ()) {double d = variTrueProbs.get (n); If (d! = Null) {if (t.getModifiers (). Get (n) == '1') {score + = (d-0.5); } And {score - = (D-0.5); }}} Return (MAT) Mathrade (score * 1000); }}
Comments
Post a Comment