@@ -975,21 +975,6 @@ private[collection] object NewRedBlackTree {
975
975
blacken(fk(t))
976
976
}
977
977
978
- def filterKeys [A , B ](t : Tree [A , B ], f : A => Boolean , isFlipped : Boolean ): Tree [A , B ] = if (t eq null ) null else {
979
- def fk (t : Tree [A , B ]): Tree [A , B ] = {
980
- val k = t.key
981
- val l = t.left
982
- val r = t.right
983
- val l2 = if (l eq null ) null else fk(l)
984
- val keep = isFlipped ^ f(k)
985
- val r2 = if (r eq null ) null else fk(r)
986
- if (! keep) join2(l2, r2)
987
- else if ((l2 eq l) && (r2 eq r)) t
988
- else join(l2, k, t.value, r2)
989
- }
990
- blacken(fk(t))
991
- }
992
-
993
978
def partitionEntries [A , B ](t : Tree [A , B ], p : (A , B ) => Boolean ): (Tree [A , B ], Tree [A , B ]) = if (t eq null ) (null , null ) else {
994
979
var tmpk, tmpd = null : Tree [A , B ] // shared vars to avoid returning tuples from fk
995
980
def fk (t : Tree [A , B ]): Unit = {
@@ -1024,40 +1009,6 @@ private[collection] object NewRedBlackTree {
1024
1009
(blacken(tmpk), blacken(tmpd))
1025
1010
}
1026
1011
1027
- def partitionKeys [A , B ](t : Tree [A , B ], p : A => Boolean ): (Tree [A , B ], Tree [A , B ]) = if (t eq null ) (null , null ) else {
1028
- var tmpk, tmpd = null : Tree [A , B ] // shared vars to avoid returning tuples from fk
1029
- def fk (t : Tree [A , B ]): Unit = {
1030
- val k = t.key
1031
- val v = t.value
1032
- val l = t.left
1033
- val r = t.right
1034
- var l2k, l2d, r2k, r2d = null : Tree [A , B ]
1035
- if (l ne null ) {
1036
- fk(l)
1037
- l2k = tmpk
1038
- l2d = tmpd
1039
- }
1040
- val keep = p(k)
1041
- if (r ne null ) {
1042
- fk(r)
1043
- r2k = tmpk
1044
- r2d = tmpd
1045
- }
1046
- val jk =
1047
- if (! keep) join2(l2k, r2k)
1048
- else if ((l2k eq l) && (r2k eq r)) t
1049
- else join(l2k, k, v, r2k)
1050
- val jd =
1051
- if (keep) join2(l2d, r2d)
1052
- else if ((l2d eq l) && (r2d eq r)) t
1053
- else join(l2d, k, v, r2d)
1054
- tmpk = jk
1055
- tmpd = jd
1056
- }
1057
- fk(t)
1058
- (blacken(tmpk), blacken(tmpd))
1059
- }
1060
-
1061
1012
1062
1013
// Based on Stefan Kahrs' Haskell version of Okasaki's Red&Black Trees
1063
1014
// Constructing Red-Black Trees, Ralf Hinze: [[http://www.cs.ox.ac.uk/ralf.hinze/publications/WAAAPL99b.ps.gz]]
0 commit comments