Support distinctBy intermediate call

This commit is contained in:
Vitaliy.Bibaev
2017-12-25 17:01:29 +03:00
committed by Yan Zhulanow
parent 0cc5e924a7
commit 89abcb82e4
10 changed files with 267 additions and 17 deletions
@@ -13,22 +13,22 @@ toList
after: nothing
mappings for distinctBy
direct:
1 -> nothing
3 -> nothing
5 -> nothing
6 -> nothing
7 -> nothing
8 -> nothing
9 -> nothing
10 -> nothing
11 -> nothing
12 -> nothing
14 -> nothing
1 -> 2
3 -> 4
5 -> 4
6 -> 4
7 -> 4
8 -> 2
9 -> 4
10 -> 2
11 -> 2
12 -> 13
14 -> 15
reverse:
nothing <- 2
nothing <- 4
nothing <- 13
nothing <- 15
1,8,10,11 <- 2
3,5,6,7,9 <- 4
12 <- 13
14 <- 15
mappings for toList
direct:
2 -> nothing
@@ -37,7 +37,6 @@ mappings for toList
15 -> nothing
reverse:
empty
WRONG!
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,32 @@
LineBreakpoint created at DistinctByNullableElement.kt:5
Run Java
Connected to the target VM
DistinctByNullableElement.kt:5
sequenceOf(null, 1, 2, 3, null)
.distinctBy({ it == null })
.count()
distinctBy
before: 1,3,5,6,7
after: 2,4
count
before: 2,4
after: nothing
mappings for distinctBy
direct:
1 -> 2
3 -> 4
5 -> 4
6 -> 4
7 -> 2
reverse:
1,7 <- 2
3,5,6 <- 4
mappings for count
direct:
2 -> nothing
4 -> nothing
reverse:
empty
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,36 @@
LineBreakpoint created at DistinctByNullableKey.kt:5
Run Java
Connected to the target VM
DistinctByNullableKey.kt:5
sequenceOf(1, 2, 3, 4, 5)
.distinctBy({ if (it % 2 == 0) null else it })
.count()
distinctBy
before: 1,3,5,7,8
after: 2,4,6,9
count
before: 2,4,6,9
after: nothing
mappings for distinctBy
direct:
1 -> 2
3 -> 4
5 -> 6
7 -> 4
8 -> 9
reverse:
1 <- 2
3,7 <- 4
5 <- 6
8 <- 9
mappings for count
direct:
2 -> nothing
4 -> nothing
6 -> nothing
9 -> nothing
reverse:
empty
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,35 @@
LineBreakpoint created at DistinctByNullableKeyAndElement.kt:5
Run Java
Connected to the target VM
DistinctByNullableKeyAndElement.kt:5
sequenceOf(1, 2, null, null, 3, 1)
.distinctBy({ if (it == null) 2 else if (it == 3) null else it })
.count()
distinctBy
before: 1,3,5,6,7,9
after: 2,4,8
count
before: 2,4,8
after: nothing
mappings for distinctBy
direct:
1 -> 2
3 -> 4
5 -> 4
6 -> 4
7 -> 8
9 -> 2
reverse:
1,9 <- 2
3,5,6 <- 4
7 <- 8
mappings for count
direct:
2 -> nothing
4 -> nothing
8 -> nothing
reverse:
empty
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,6 @@
package distinct
fun main(args: Array<String>) {
// Breakpoint!
sequenceOf(null, 1, 2, 3, null).distinctBy { it == null }.count()
}
@@ -0,0 +1,6 @@
package distinct
fun main(args: Array<String>) {
// Breakpoint!
sequenceOf(1, 2, 3, 4, 5).distinctBy { if (it % 2 == 0) null else it }.count()
}
@@ -0,0 +1,6 @@
package distinct
fun main(args: Array<String>) {
// Breakpoint!
sequenceOf(1, 2, null, null, 3, 1).distinctBy { if (it == null) 2 else if (it == 3) null else it }.count()
}