@@ -851,22 +851,22 @@ private[collection] object RedBlackTree {
851
851
852
852
private [this ] def _union [A , B ](t1 : Tree [A , B ], t2 : Tree [A , B ])(implicit ordering : Ordering [A ]): Tree [A , B ] =
853
853
if ((t1 eq null ) || (t1 eq t2)) t2
854
- else if (t2 eq null ) t1
854
+ else if (t1 eq null ) t2
855
855
else {
856
- val (l1 , _, r1 ) = split(t1, t2 .key)
857
- val tl = _union(l1, t2 .left)
858
- val tr = _union(r1, t2 .right)
859
- join(tl, t2 .key, t2 .value, tr)
856
+ val (l2 , _, r2 ) = split(t2, t1 .key)
857
+ val tl = _union(t1 .left, l2 )
858
+ val tr = _union(t1 .right, r2 )
859
+ join(tl, t1 .key, t1 .value, tr)
860
860
}
861
861
862
862
private [this ] def _intersect [A , B ](t1 : Tree [A , B ], t2 : Tree [A , B ])(implicit ordering : Ordering [A ]): Tree [A , B ] =
863
863
if ((t1 eq null ) || (t2 eq null )) null
864
864
else if (t1 eq t2) t1
865
865
else {
866
- val (l1 , b, r1 ) = split(t1, t2 .key)
867
- val tl = _intersect(l1, t2 .left)
868
- val tr = _intersect(r1, t2 .right)
869
- if (b ne null ) join(tl, t2 .key, t2 .value, tr)
866
+ val (l2 , b, r2 ) = split(t2, t1 .key)
867
+ val tl = _intersect(t1 .left, l2 )
868
+ val tr = _intersect(t1 .right, r2 )
869
+ if (b ne null ) join(tl, t1 .key, t1 .value, tr)
870
870
else join2(tl, tr)
871
871
}
872
872
0 commit comments