Another pattern for min/max supported

This commit is contained in:
Valentin Kipyatkov
2016-08-17 19:30:03 +03:00
parent 930f7960ea
commit 84fd24a1a0
12 changed files with 207 additions and 12 deletions
+13
View File
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.max()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.max()'"
fun getMaxLineWidth(lineCount: Int): Float {
var max_width = 0.0f
<caret>for (i in 0..lineCount - 1) {
val width = getLineWidth(i)
max_width = if (width > max_width) width else max_width
}
return max_width
}
fun getLineWidth(i: Int): Float = TODO()
+12
View File
@@ -0,0 +1,12 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.max()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.max()'"
fun getMaxLineWidth(lineCount: Int): Float {
val <caret>max_width = (0..lineCount - 1)
.map { getLineWidth(it) }
.max()
?: 0.0f
return max_width
}
fun getLineWidth(i: Int): Float = TODO()
+13
View File
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.max()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.max()'"
fun getMaxLineWidth(lineCount: Int): Float {
val <caret>max_width = (0..lineCount - 1)
.asSequence()
.map { getLineWidth(it) }
.max()
?: 0.0f
return max_width
}
fun getLineWidth(i: Int): Float = TODO()
+13
View File
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.min()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.min()'"
fun getMinLineWidth(lineCount: Int): Double {
var min_width = Double.MAX_VALUE
<caret>for (i in 0..lineCount - 1) {
val width = getLineWidth(i)
min_width = if (min_width > width) min_width else width
}
return min_width
}
fun getLineWidth(i: Int): Double = TODO()
+12
View File
@@ -0,0 +1,12 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.min()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.min()'"
fun getMinLineWidth(lineCount: Int): Double {
val <caret>min_width = (0..lineCount - 1)
.map { getLineWidth(it) }
.min()
?: Double.MAX_VALUE
return min_width
}
fun getLineWidth(i: Int): Double = TODO()
+13
View File
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.min()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.min()'"
fun getMinLineWidth(lineCount: Int): Double {
val <caret>min_width = (0..lineCount - 1)
.asSequence()
.map { getLineWidth(it) }
.min()
?: Double.MAX_VALUE
return min_width
}
fun getLineWidth(i: Int): Double = TODO()
+13
View File
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.min()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.min()'"
fun getMinLineWidth(lineCount: Int): Double {
var min_width = Double.MAX_VALUE
<caret>for (i in 0..lineCount - 1) {
val width = getLineWidth(i)
min_width = if (min_width >= width) width else min_width
}
return min_width
}
fun getLineWidth(i: Int): Double = TODO()
+12
View File
@@ -0,0 +1,12 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.min()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.min()'"
fun getMinLineWidth(lineCount: Int): Double {
val <caret>min_width = (0..lineCount - 1)
.map { getLineWidth(it) }
.min()
?: Double.MAX_VALUE
return min_width
}
fun getLineWidth(i: Int): Double = TODO()
+13
View File
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.min()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.min()'"
fun getMinLineWidth(lineCount: Int): Double {
val <caret>min_width = (0..lineCount - 1)
.asSequence()
.map { getLineWidth(it) }
.min()
?: Double.MAX_VALUE
return min_width
}
fun getLineWidth(i: Int): Double = TODO()