StdLib cleanup, deprecated symbol usage: size() and length()

This commit is contained in:
Ilya Gorbunov
2015-11-14 05:56:57 +03:00
parent 21e2e68ed4
commit 07654eb82b
59 changed files with 730 additions and 730 deletions
@@ -60,7 +60,7 @@ public abstract class KotlinAnnotationProvider {
val shortenedValue = shortenedPackageNameCache.get(id) ?:
throw RuntimeException("Value for $id couldn't be found in shrink cache")
return shortenedValue + '.' + s.substring(id.length() + 1)
return shortenedValue + '.' + s.substring(id.length + 1)
}
val annotatedKotlinElements: MutableMap<String, MutableSet<AnnotatedElementDescriptor>> = hashMapOf()
@@ -82,7 +82,7 @@ public abstract class KotlinAnnotationProvider {
ANNOTATED_CLASS, ANNOTATED_FIELD, ANNOTATED_METHOD -> {
val annotationName = expandAnnotation(lineParts[1])
val classFqName = expandClassName(lineParts[2]).replace('$', '.')
val elementName = if (lineParts.size() == 4) lineParts[3] else null
val elementName = if (lineParts.size == 4) lineParts[3] else null
val set = annotatedKotlinElements.getOrPut(annotationName) { hashSetOf() }
set.add(when (type) {
@@ -271,7 +271,7 @@ public class AnnotationProcessingManager(
modifyCompilerArguments { args ->
val argIndex = args.indexOfFirst { name == it }
if (argIndex >= 0 && args.size() > (argIndex + 1)) {
if (argIndex >= 0 && args.size > (argIndex + 1)) {
args[argIndex + 1] = value(args[argIndex + 1])
}
else {
@@ -334,7 +334,7 @@ public class AnnotationProcessingManager(
}
private fun invokeCoreKaptMethod(methodName: String, vararg args: Any): Any {
val array = arrayOfNulls<Class<*>>(args.size())
val array = arrayOfNulls<Class<*>>(args.size)
args.forEachIndexed { i, arg -> array[i] = arg.javaClass }
val method = getCoreKaptPackageClass().getMethod(methodName, *array)
return method.invoke(null, *args)
@@ -36,7 +36,7 @@ private fun comparableVersionStr(version: String) =
?.groups
?.drop(1)?.take(2)
// checking if two subexpression groups are found and length of each is >0 and <4
?.let { if (it.all { (it?.value?.length() ?: 0).let { it > 0 && it < 4 }}) it else null }
?.let { if (it.all { (it?.value?.length ?: 0).let { it > 0 && it < 4 }}) it else null }
?.joinToString(".", transform = { it!!.value.padStart(3, '0') })
@@ -157,7 +157,7 @@ class Kotlin2JvmSourceSetProcessor(
val subpluginEnvironment = loadSubplugins(project)
subpluginEnvironment.addSubpluginArguments(project, kotlinTask)
if (aptConfiguration.getDependencies().size() > 1 && javaTask is JavaCompile) {
if (aptConfiguration.getDependencies().size > 1 && javaTask is JavaCompile) {
val (aptOutputDir, aptWorkingDir) = project.getAptDirsForSourceSet(sourceSetName)
val kaptManager = AnnotationProcessingManager(kotlinTask, javaTask, sourceSetName,
@@ -389,7 +389,7 @@ open class KotlinAndroidPlugin @Inject constructor(val scriptHandler: ScriptHand
val aptConfiguration = aptConfigurations[(provider as AndroidSourceSet).getName()]
// Ignore if there's only an annotation processor wrapper in dependencies (added by default)
if (aptConfiguration != null && aptConfiguration.getDependencies().size() > 1) {
if (aptConfiguration != null && aptConfiguration.getDependencies().size > 1) {
aptFiles.addAll(aptConfiguration.resolve())
}
}
@@ -598,7 +598,7 @@ private fun compareVersionNumbers(v1: String?, v2: String?): Int {
val part2 = v2.split(pattern)
var idx = 0
while (idx < part1.size() && idx < part2.size()) {
while (idx < part1.size && idx < part2.size) {
val p1 = part1[idx]
val p2 = part2[idx]
@@ -612,13 +612,13 @@ private fun compareVersionNumbers(v1: String?, v2: String?): Int {
idx++
}
if (part1.size() == part2.size()) {
if (part1.size == part2.size) {
return 0
} else {
val left = part1.size() > idx
val left = part1.size > idx
val parts = if (left) part1 else part2
while (idx < parts.size()) {
while (idx < parts.size) {
val p = parts[idx]
val cmp: Int
if (p.matches(digitsPattern)) {
@@ -65,7 +65,7 @@ class KotlinGradleIT: BaseGradleIT() {
project.build(userVariantArg, "build", options = BaseGradleIT.BuildOptions(withDaemon = true)) {
assertSuccessful()
val matches = "\\[PERF\\] Used memory after build: (\\d+) kb \\(([+-]?\\d+) kb\\)".toRegex().find(output)
assert(matches != null && matches.groups.size() == 3) { "Used memory after build is not reported by plugin" }
assert(matches != null && matches.groups.size == 3) { "Used memory after build is not reported by plugin" }
val reportedGrowth = matches!!.groups.get(2)!!.value.removePrefix("+").toInt()
assert(reportedGrowth <= 700) { "Used memory growth $reportedGrowth > 700" }
}
@@ -106,10 +106,10 @@ fun aggregates(): List<GenericFunction> {
deprecate(Strings) { forBinaryCompatibility }
doc(CharSequences) { "Returns the length of this char sequence."}
body(CharSequences, Strings) {
"return length()"
"return length"
}
body(Maps, Collections, ArraysOfObjects, ArraysOfPrimitives) {
"return size()"
"return size"
}
}
@@ -10,7 +10,7 @@ fun arrays(): List<GenericFunction> {
doc { "Returns `true` if the array is empty." }
returns("Boolean")
body {
"return size() == 0"
"return size == 0"
}
}
@@ -41,7 +41,7 @@ fun arrays(): List<GenericFunction> {
doc { "Returns the last valid index for the array." }
returns("Int")
body {
"get() = size() - 1"
"get() = size - 1"
}
}
@@ -65,7 +65,7 @@ fun arrays(): List<GenericFunction> {
// TODO: Use different implementations for JS
body {
"""
val result = $arrayType(size())
val result = $arrayType(size)
for (index in indices)
result[index] = this[index]
return result
@@ -73,7 +73,7 @@ fun arrays(): List<GenericFunction> {
}
body(Collections) {
"""
val result = $arrayType(size())
val result = $arrayType(size)
var index = 0
for (element in this)
result[index++] = element
@@ -577,7 +577,7 @@ fun elements(): List<GenericFunction> {
body {
"""
when (this) {
is List -> return if (isEmpty()) null else this[size() - 1]
is List -> return if (isEmpty()) null else this[size - 1]
else -> {
val iterator = iterator()
if (!iterator.hasNext())
@@ -604,12 +604,12 @@ fun elements(): List<GenericFunction> {
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
"""
return if (isEmpty()) null else this[length() - 1]
return if (isEmpty()) null else this[length - 1]
"""
}
body(Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
return if (isEmpty()) null else this[size() - 1]
return if (isEmpty()) null else this[size - 1]
"""
}
}
@@ -704,7 +704,7 @@ fun elements(): List<GenericFunction> {
body {
"""
when (this) {
is List -> return when (size()) {
is List -> return when (size) {
0 -> throw NoSuchElementException("Collection is empty.")
1 -> this[0]
else -> throw IllegalArgumentException("Collection has more than one element.")
@@ -735,7 +735,7 @@ fun elements(): List<GenericFunction> {
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
"""
return when (length()) {
return when (length) {
0 -> throw NoSuchElementException("Collection is empty.")
1 -> this[0]
else -> throw IllegalArgumentException("Collection has more than one element.")
@@ -744,7 +744,7 @@ fun elements(): List<GenericFunction> {
}
body(Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
return when (size()) {
return when (size) {
0 -> throw NoSuchElementException("Collection is empty.")
1 -> this[0]
else -> throw IllegalArgumentException("Collection has more than one element.")
@@ -759,7 +759,7 @@ fun elements(): List<GenericFunction> {
body {
"""
when (this) {
is List -> return if (size() == 1) this[0] else null
is List -> return if (size == 1) this[0] else null
else -> {
val iterator = iterator()
if (!iterator.hasNext())
@@ -786,12 +786,12 @@ fun elements(): List<GenericFunction> {
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
"""
return if (length() == 1) this[0] else null
return if (length == 1) this[0] else null
"""
}
body(Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
return if (size() == 1) this[0] else null
return if (size == 1) this[0] else null
"""
}
}
@@ -30,13 +30,13 @@ fun filtering(): List<GenericFunction> {
if (n == 0) return toList()
val list: ArrayList<T>
if (this is Collection<*>) {
val resultSize = size() - n
val resultSize = size - n
if (resultSize <= 0)
return emptyList()
list = ArrayList<T>(resultSize)
if (this is List<T>) {
for (index in n..size() - 1) {
for (index in n..size - 1) {
list.add(this[index])
}
return list
@@ -77,11 +77,11 @@ fun filtering(): List<GenericFunction> {
require(n >= 0, { "Requested element count $n is less than zero." })
if (n == 0)
return toList()
if (n >= size())
if (n >= size)
return emptyList()
val list = ArrayList<T>(size() - n)
for (index in n..size() - 1) {
val list = ArrayList<T>(size - n)
for (index in n..size - 1) {
list.add(this[index])
}
return list
@@ -97,7 +97,7 @@ fun filtering(): List<GenericFunction> {
"""
require(n >= 0, { "Requested element count $n is less than zero." })
if (n == 0) return emptyList()
if (this is Collection<T> && n >= size()) return toList()
if (this is Collection<T> && n >= size) return toList()
var count = 0
val list = ArrayList<T>(n)
for (item in this) {
@@ -132,7 +132,7 @@ fun filtering(): List<GenericFunction> {
"""
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
if (n >= size()) return toList()
if (n >= size) return toList()
var count = 0
val list = ArrayList<T>(n)
for (item in this) {
@@ -154,7 +154,7 @@ fun filtering(): List<GenericFunction> {
body {
"""
require(n >= 0, { "Requested element count $n is less than zero." })
return take((size() - n).coerceAtLeast(0))
return take((size - n).coerceAtLeast(0))
"""
}
@@ -192,7 +192,7 @@ fun filtering(): List<GenericFunction> {
"""
require(n >= 0, { "Requested element count $n is less than zero." })
if (n == 0) return emptyList()
val size = size()
val size = size
if (n >= size) return toList()
val list = ArrayList<T>(n)
for (index in size - n .. size - 1)
@@ -390,7 +390,7 @@ fun filtering(): List<GenericFunction> {
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
"""
for (index in 0..length() - 1) {
for (index in 0..length - 1) {
val element = get(index)
if (predicate(element)) destination.append(element)
}
@@ -593,7 +593,7 @@ fun filtering(): List<GenericFunction> {
returns("SELF")
body(ArraysOfObjects) {
"""
val result = arrayOfNulls(this, indices.size()) as Array<T>
val result = arrayOfNulls(this, indices.size) as Array<T>
var targetIndex = 0
for (sourceIndex in indices) {
result[targetIndex++] = this[sourceIndex]
@@ -603,7 +603,7 @@ fun filtering(): List<GenericFunction> {
}
body(ArraysOfPrimitives) {
"""
val result = SELF(indices.size())
val result = SELF(indices.size)
var targetIndex = 0
for (sourceIndex in indices) {
result[targetIndex++] = this[sourceIndex]
@@ -23,7 +23,7 @@ fun generators(): List<GenericFunction> {
}
body(Collections) {
"""
val result = ArrayList<T>(size() + 1)
val result = ArrayList<T>(size + 1)
result.addAll(this)
result.add(element)
return result
@@ -36,7 +36,7 @@ fun generators(): List<GenericFunction> {
doc(Sets) { "Returns a set containing all elements of the original set and then the given [element]." }
body(Sets) {
"""
val result = LinkedHashSet<T>(mapCapacity(size() + 1))
val result = LinkedHashSet<T>(mapCapacity(size + 1))
result.addAll(this)
result.add(element)
return result
@@ -70,7 +70,7 @@ fun generators(): List<GenericFunction> {
body(Collections) {
"""
if (collection is Collection) {
val result = ArrayList<T>(this.size() + collection.size())
val result = ArrayList<T>(this.size + collection.size)
result.addAll(this)
result.addAll(collection)
return result
@@ -86,7 +86,7 @@ fun generators(): List<GenericFunction> {
doc(Sets) { "Returns a set containing all elements both of the original set and the given [collection]." }
body(Sets) {
"""
val result = LinkedHashSet<T>(mapCapacity(collection.collectionSizeOrNull()?.let { this.size() + it } ?: this.size() * 2))
val result = LinkedHashSet<T>(mapCapacity(collection.collectionSizeOrNull()?.let { this.size + it } ?: this.size * 2))
result.addAll(this)
result.addAll(collection)
return result
@@ -126,7 +126,7 @@ fun generators(): List<GenericFunction> {
}
body(Collections) {
"""
val result = ArrayList<T>(this.size() + array.size())
val result = ArrayList<T>(this.size + array.size)
result.addAll(this)
result.addAll(array)
return result
@@ -135,7 +135,7 @@ fun generators(): List<GenericFunction> {
doc(Sets) { "Returns a set containing all elements both of the original set and the given [array]." }
body(Sets) {
"""
val result = LinkedHashSet<T>(mapCapacity(this.size() + array.size()))
val result = LinkedHashSet<T>(mapCapacity(this.size + array.size))
result.addAll(this)
result.addAll(array)
return result
@@ -174,7 +174,7 @@ fun generators(): List<GenericFunction> {
}
body(Collections) {
"""
val result = ArrayList<T>(this.size() + 10)
val result = ArrayList<T>(this.size + 10)
result.addAll(this)
result.addAll(sequence)
return result
@@ -185,7 +185,7 @@ fun generators(): List<GenericFunction> {
doc(Sets) { "Returns a set containing all elements both of the original set and the given [sequence]." }
body(Sets) {
"""
val result = LinkedHashSet<T>(mapCapacity(this.size() * 2))
val result = LinkedHashSet<T>(mapCapacity(this.size * 2))
result.addAll(this)
result.addAll(sequence)
return result
@@ -225,7 +225,7 @@ fun generators(): List<GenericFunction> {
doc(Sets) { "Returns a set containing all elements of the original set except the given [element]." }
body(Sets) {
"""
val result = LinkedHashSet<T>(mapCapacity(size()))
val result = LinkedHashSet<T>(mapCapacity(size))
var removed = false
return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }
"""
@@ -469,7 +469,7 @@ fun generators(): List<GenericFunction> {
}
body(ArraysOfObjects, ArraysOfPrimitives) {
"""
val arraySize = size()
val arraySize = size
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
var i = 0
for (element in other) {
@@ -494,7 +494,7 @@ fun generators(): List<GenericFunction> {
inline(true)
body {
"""
val arraySize = array.size()
val arraySize = array.size
val list = ArrayList<V>(Math.min(collectionSizeOrDefault(10), arraySize))
var i = 0
for (element in this) {
@@ -506,7 +506,7 @@ fun generators(): List<GenericFunction> {
}
body(ArraysOfObjects, ArraysOfPrimitives) {
"""
val size = Math.min(size(), array.size())
val size = Math.min(size, array.size)
val list = ArrayList<V>(size)
for (i in 0..size-1) {
list.add(transform(this[i], array[i]))
@@ -529,7 +529,7 @@ fun generators(): List<GenericFunction> {
inline(true)
body() {
"""
val size = Math.min(size(), array.size())
val size = Math.min(size, array.size)
val list = ArrayList<V>(size)
for (i in 0..size-1) {
list.add(transform(this[i], array[i]))
@@ -569,7 +569,7 @@ fun generators(): List<GenericFunction> {
inline(true)
body {
"""
val length = Math.min(this.length(), other.length())
val length = Math.min(this.length, other.length)
val list = ArrayList<V>(length)
for (i in 0..length-1) {
@@ -42,11 +42,11 @@ fun mapping(): List<GenericFunction> {
"return mapIndexedTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)"
}
body(ArraysOfObjects, ArraysOfPrimitives) {
"return mapIndexedTo(ArrayList<R>(size()), transform)"
"return mapIndexedTo(ArrayList<R>(size), transform)"
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
"return mapIndexedTo(ArrayList<R>(length()), transform)"
"return mapIndexedTo(ArrayList<R>(length), transform)"
}
inline(false, Sequences)
returns(Sequences) { "Sequence<R>" }
@@ -70,11 +70,11 @@ fun mapping(): List<GenericFunction> {
"return mapTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)"
}
body(ArraysOfObjects, ArraysOfPrimitives, Maps) {
"return mapTo(ArrayList<R>(size()), transform)"
"return mapTo(ArrayList<R>(size), transform)"
}
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
"return mapTo(ArrayList<R>(length()), transform)"
"return mapTo(ArrayList<R>(length), transform)"
}
inline(false, Sequences)
@@ -68,7 +68,7 @@ fun ordering(): List<GenericFunction> {
body(ArraysOfObjects) {
"""
if (isEmpty()) return this
val result = arrayOfNulls(this, size()) as Array<T>
val result = arrayOfNulls(this, size) as Array<T>
val lastIndex = lastIndex
for (i in 0..lastIndex)
result[lastIndex - i] = this[i]
@@ -78,7 +78,7 @@ fun ordering(): List<GenericFunction> {
body(ArraysOfPrimitives) {
"""
if (isEmpty()) return this
val result = SELF(size())
val result = SELF(size)
val lastIndex = lastIndex
for (i in 0..lastIndex)
result[lastIndex - i] = this[i]
@@ -22,7 +22,7 @@ fun sets(): List<GenericFunction> {
}
body(ArraysOfObjects, ArraysOfPrimitives) {
"""
val set = LinkedHashSet<T>(mapCapacity(size()))
val set = LinkedHashSet<T>(mapCapacity(size))
for (item in this) set.add(item)
return set
"""
@@ -29,8 +29,8 @@ fun snapshots(): List<GenericFunction> {
body { "return toCollection(LinkedHashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
body(Sequences) { "return toCollection(LinkedHashSet<T>())" }
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) { "return toCollection(LinkedHashSet<T>(mapCapacity(length())))" }
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(LinkedHashSet<T>(mapCapacity(size())))" }
body(CharSequences, Strings) { "return toCollection(LinkedHashSet<T>(mapCapacity(length)))" }
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(LinkedHashSet<T>(mapCapacity(size)))" }
}
templates add f("toHashSet()") {
@@ -39,8 +39,8 @@ fun snapshots(): List<GenericFunction> {
body { "return toCollection(HashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
body(Sequences) { "return toCollection(HashSet<T>())" }
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) { "return toCollection(HashSet<T>(mapCapacity(length())))" }
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(HashSet<T>(mapCapacity(size())))" }
body(CharSequences, Strings) { "return toCollection(HashSet<T>(mapCapacity(length)))" }
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(HashSet<T>(mapCapacity(size)))" }
}
templates add f("toSortedSet()") {
@@ -64,11 +64,11 @@ fun snapshots(): List<GenericFunction> {
}
body(Collections) { "return ArrayList(this)" }
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) { "return toCollection(ArrayList<T>(length()))" }
body(CharSequences, Strings) { "return toCollection(ArrayList<T>(length))" }
body(ArraysOfObjects) { "return ArrayList(this.asCollection())" }
body(ArraysOfPrimitives) {
"""
val list = ArrayList<T>(size())
val list = ArrayList<T>(size)
for (item in this) list.add(item)
return list
"""
@@ -81,7 +81,7 @@ fun snapshots(): List<GenericFunction> {
returns("List<Pair<K, V>>")
body {
"""
val result = ArrayList<Pair<K, V>>(size())
val result = ArrayList<Pair<K, V>>(size)
for (item in this)
result.add(item.key to item.value)
return result
@@ -153,7 +153,7 @@ fun snapshots(): List<GenericFunction> {
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
"""
val capacity = (length()/.75f) + 1
val capacity = (length/.75f) + 1
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
for (element in this) {
result.put(selector(element), element)
@@ -163,7 +163,7 @@ fun snapshots(): List<GenericFunction> {
}
body(ArraysOfObjects, ArraysOfPrimitives) {
"""
val capacity = (size()/.75f) + 1
val capacity = (size/.75f) + 1
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
for (element in this) {
result.put(selector(element), element)
@@ -212,7 +212,7 @@ fun snapshots(): List<GenericFunction> {
deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) {
"""
val capacity = (length()/.75f) + 1
val capacity = (length/.75f) + 1
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
for (element in this) {
result.put(selector(element), transform(element))
@@ -222,7 +222,7 @@ fun snapshots(): List<GenericFunction> {
}
body(ArraysOfObjects, ArraysOfPrimitives) {
"""
val capacity = (size()/.75f) + 1
val capacity = (size/.75f) + 1
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
for (element in this) {
result.put(selector(element), transform(element))
@@ -13,7 +13,7 @@ fun specialJVM(): List<GenericFunction> {
doc { "Returns an array containing all elements of the original array and then the given [element]." }
body() {
"""
val index = size()
val index = size
val result = Arrays.copyOf(this, index + 1)
result[index] = element
return result
@@ -29,8 +29,8 @@ fun specialJVM(): List<GenericFunction> {
doc { "Returns an array containing all elements of the original array and then all elements of the given [collection]." }
body {
"""
var index = size()
val result = Arrays.copyOf(this, index + collection.size())
var index = size
val result = Arrays.copyOf(this, index + collection.size)
for (element in collection) result[index++] = element
return result
"""
@@ -46,8 +46,8 @@ fun specialJVM(): List<GenericFunction> {
returns("SELF")
body {
"""
val thisSize = size()
val arraySize = array.size()
val thisSize = size
val arraySize = array.size
val result = Arrays.copyOf(this, thisSize + arraySize)
System.arraycopy(array, 0, result, thisSize, arraySize)
return result
@@ -72,7 +72,7 @@ fun specialJVM(): List<GenericFunction> {
returns("SELF")
annotations(InvariantArraysOfObjects) { """@JvmName("mutableCopyOf")"""}
body {
"return Arrays.copyOf(this, size())"
"return Arrays.copyOf(this, size)"
}
}
@@ -89,7 +89,7 @@ fun specialJVM(): List<GenericFunction> {
annotations(InvariantArraysOfObjects) { """@JvmName("mutableCopyOf")"""}
}
templates add f("fill(element: T, fromIndex: Int = 0, toIndex: Int = size())") {
templates add f("fill(element: T, fromIndex: Int = 0, toIndex: Int = size)") {
only(InvariantArraysOfObjects, ArraysOfPrimitives)
doc { "Fills original array with the provided value." }
returns { "Unit" }
@@ -100,7 +100,7 @@ fun specialJVM(): List<GenericFunction> {
}
}
templates add f("binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size())") {
templates add f("binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size)") {
only(ArraysOfObjects, ArraysOfPrimitives)
exclude(PrimitiveType.Boolean)
doc { "Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted." }
@@ -110,7 +110,7 @@ fun specialJVM(): List<GenericFunction> {
}
}
templates add f("binarySearch(element: T, comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size())") {
templates add f("binarySearch(element: T, comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size)") {
only(ArraysOfObjects)
doc { "Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted according to the specified [comparator]." }
returns("Int")
@@ -130,7 +130,7 @@ fun specialJVM(): List<GenericFunction> {
}
}
templates add f("sort(fromIndex: Int = 0, toIndex: Int = size())") {
templates add f("sort(fromIndex: Int = 0, toIndex: Int = size)") {
only(ArraysOfObjects, ArraysOfPrimitives)
exclude(PrimitiveType.Boolean)
doc { "Sorts a range in the array in-place." }
@@ -149,7 +149,7 @@ fun specialJVM(): List<GenericFunction> {
}
}
templates add f("sortWith(comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size())") {
templates add f("sortWith(comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size)") {
only(ArraysOfObjects)
doc { "Sorts a range in the array in-place with the given [comparator]." }
returns("Unit")
@@ -247,7 +247,7 @@ fun specialJVM(): List<GenericFunction> {
body(ArraysOfPrimitives) {
"""
return object : AbstractList<T>(), RandomAccess {
override val size: Int get() = this@asList.size()
override val size: Int get() = this@asList.size
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: T): Boolean = this@asList.contains(o)
override fun get(index: Int): T = this@asList[index]
@@ -268,7 +268,7 @@ fun specialJVM(): List<GenericFunction> {
}
body {
"""
val result = arrayOfNulls<T>(size())
val result = arrayOfNulls<T>(size)
for (index in indices)
result[index] = this[index]
return result as Array<T>