Introduce annotation InlineExposed to indicate internal members effectively public due to usage in inlined functions.
Currently, doesn't affect anything. Make collectionSizeOrDefault and collectionSizeOrNull internal, but expose them via inlining together with mapCapacity. Make Regex(Pattern) constructor exposed by inlined Pattern.toRegex
This commit is contained in:
@@ -5491,7 +5491,8 @@ public fun Array<out Short>.toShortArray(): ShortArray {
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Array<out T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5501,7 +5502,8 @@ public inline fun <T, K, V> Array<out T>.associate(transform: (T) -> Pair<K, V>)
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> BooleanArray.associate(transform: (Boolean) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5511,7 +5513,8 @@ public inline fun <K, V> BooleanArray.associate(transform: (Boolean) -> Pair<K,
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> ByteArray.associate(transform: (Byte) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5521,7 +5524,8 @@ public inline fun <K, V> ByteArray.associate(transform: (Byte) -> Pair<K, V>): M
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> CharArray.associate(transform: (Char) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5531,7 +5535,8 @@ public inline fun <K, V> CharArray.associate(transform: (Char) -> Pair<K, V>): M
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> DoubleArray.associate(transform: (Double) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5541,7 +5546,8 @@ public inline fun <K, V> DoubleArray.associate(transform: (Double) -> Pair<K, V>
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> FloatArray.associate(transform: (Float) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5551,7 +5557,8 @@ public inline fun <K, V> FloatArray.associate(transform: (Float) -> Pair<K, V>):
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> IntArray.associate(transform: (Int) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5561,7 +5568,8 @@ public inline fun <K, V> IntArray.associate(transform: (Int) -> Pair<K, V>): Map
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> LongArray.associate(transform: (Long) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5571,7 +5579,8 @@ public inline fun <K, V> LongArray.associate(transform: (Long) -> Pair<K, V>): M
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> ShortArray.associate(transform: (Short) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -5581,7 +5590,8 @@ public inline fun <K, V> ShortArray.associate(transform: (Short) -> Pair<K, V>):
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K> Array<out T>.associateBy(keySelector: (T) -> K): Map<K, T> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, T>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5591,7 +5601,8 @@ public inline fun <T, K> Array<out T>.associateBy(keySelector: (T) -> K): Map<K,
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> BooleanArray.associateBy(keySelector: (Boolean) -> K): Map<K, Boolean> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Boolean>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5601,7 +5612,8 @@ public inline fun <K> BooleanArray.associateBy(keySelector: (Boolean) -> K): Map
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> ByteArray.associateBy(keySelector: (Byte) -> K): Map<K, Byte> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Byte>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5611,7 +5623,8 @@ public inline fun <K> ByteArray.associateBy(keySelector: (Byte) -> K): Map<K, By
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> CharArray.associateBy(keySelector: (Char) -> K): Map<K, Char> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Char>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5621,7 +5634,8 @@ public inline fun <K> CharArray.associateBy(keySelector: (Char) -> K): Map<K, Ch
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> DoubleArray.associateBy(keySelector: (Double) -> K): Map<K, Double> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Double>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5631,7 +5645,8 @@ public inline fun <K> DoubleArray.associateBy(keySelector: (Double) -> K): Map<K
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> FloatArray.associateBy(keySelector: (Float) -> K): Map<K, Float> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Float>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5641,7 +5656,8 @@ public inline fun <K> FloatArray.associateBy(keySelector: (Float) -> K): Map<K,
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> IntArray.associateBy(keySelector: (Int) -> K): Map<K, Int> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Int>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5651,7 +5667,8 @@ public inline fun <K> IntArray.associateBy(keySelector: (Int) -> K): Map<K, Int>
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> LongArray.associateBy(keySelector: (Long) -> K): Map<K, Long> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Long>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5661,7 +5678,8 @@ public inline fun <K> LongArray.associateBy(keySelector: (Long) -> K): Map<K, Lo
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> ShortArray.associateBy(keySelector: (Short) -> K): Map<K, Short> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Short>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -5670,7 +5688,8 @@ public inline fun <K> ShortArray.associateBy(keySelector: (Short) -> K): Map<K,
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Array<out T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -5679,7 +5698,8 @@ public inline fun <T, K, V> Array<out T>.associateBy(keySelector: (T) -> K, valu
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> BooleanArray.associateBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -5688,7 +5708,8 @@ public inline fun <K, V> BooleanArray.associateBy(keySelector: (Boolean) -> K, v
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> ByteArray.associateBy(keySelector: (Byte) -> K, valueTransform: (Byte) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -5697,7 +5718,8 @@ public inline fun <K, V> ByteArray.associateBy(keySelector: (Byte) -> K, valueTr
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> CharArray.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -5706,7 +5728,8 @@ public inline fun <K, V> CharArray.associateBy(keySelector: (Char) -> K, valueTr
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> DoubleArray.associateBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -5715,7 +5738,8 @@ public inline fun <K, V> DoubleArray.associateBy(keySelector: (Double) -> K, val
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> FloatArray.associateBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -5724,7 +5748,8 @@ public inline fun <K, V> FloatArray.associateBy(keySelector: (Float) -> K, value
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> IntArray.associateBy(keySelector: (Int) -> K, valueTransform: (Int) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -5733,7 +5758,8 @@ public inline fun <K, V> IntArray.associateBy(keySelector: (Int) -> K, valueTran
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> LongArray.associateBy(keySelector: (Long) -> K, valueTransform: (Long) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -5742,7 +5768,8 @@ public inline fun <K, V> LongArray.associateBy(keySelector: (Long) -> K, valueTr
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> ShortArray.associateBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map<K, V> {
|
||||
val capacity = ((size/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(size).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -11356,6 +11383,7 @@ public infix fun <R> ShortArray.zip(other: Iterable<R>): List<Pair<Short, R>> {
|
||||
*/
|
||||
public inline fun <T, R, V> Array<out T>.zip(other: Iterable<R>, transform: (T, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
@@ -11370,6 +11398,7 @@ public inline fun <T, R, V> Array<out T>.zip(other: Iterable<R>, transform: (T,
|
||||
*/
|
||||
public inline fun <R, V> BooleanArray.zip(other: Iterable<R>, transform: (Boolean, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
@@ -11384,6 +11413,7 @@ public inline fun <R, V> BooleanArray.zip(other: Iterable<R>, transform: (Boolea
|
||||
*/
|
||||
public inline fun <R, V> ByteArray.zip(other: Iterable<R>, transform: (Byte, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
@@ -11398,6 +11428,7 @@ public inline fun <R, V> ByteArray.zip(other: Iterable<R>, transform: (Byte, R)
|
||||
*/
|
||||
public inline fun <R, V> CharArray.zip(other: Iterable<R>, transform: (Char, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
@@ -11412,6 +11443,7 @@ public inline fun <R, V> CharArray.zip(other: Iterable<R>, transform: (Char, R)
|
||||
*/
|
||||
public inline fun <R, V> DoubleArray.zip(other: Iterable<R>, transform: (Double, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
@@ -11426,6 +11458,7 @@ public inline fun <R, V> DoubleArray.zip(other: Iterable<R>, transform: (Double,
|
||||
*/
|
||||
public inline fun <R, V> FloatArray.zip(other: Iterable<R>, transform: (Float, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
@@ -11440,6 +11473,7 @@ public inline fun <R, V> FloatArray.zip(other: Iterable<R>, transform: (Float, R
|
||||
*/
|
||||
public inline fun <R, V> IntArray.zip(other: Iterable<R>, transform: (Int, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
@@ -11454,6 +11488,7 @@ public inline fun <R, V> IntArray.zip(other: Iterable<R>, transform: (Int, R) ->
|
||||
*/
|
||||
public inline fun <R, V> LongArray.zip(other: Iterable<R>, transform: (Long, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
@@ -11468,6 +11503,7 @@ public inline fun <R, V> LongArray.zip(other: Iterable<R>, transform: (Long, R)
|
||||
*/
|
||||
public inline fun <R, V> ShortArray.zip(other: Iterable<R>, transform: (Short, R) -> V): List<V> {
|
||||
val arraySize = size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(other.collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in other) {
|
||||
|
||||
@@ -926,7 +926,8 @@ public fun Collection<Short>.toShortArray(): ShortArray {
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((collectionSizeOrDefault(10)/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -936,7 +937,8 @@ public inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>):
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K> Iterable<T>.associateBy(keySelector: (T) -> K): Map<K, T> {
|
||||
val capacity = ((collectionSizeOrDefault(10)/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, T>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -945,7 +947,8 @@ public inline fun <T, K> Iterable<T>.associateBy(keySelector: (T) -> K): Map<K,
|
||||
* If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <T, K, V> Iterable<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {
|
||||
val capacity = ((collectionSizeOrDefault(10)/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
@@ -1165,6 +1168,7 @@ public inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.gr
|
||||
* Returns a list containing the results of applying the given [transform] function
|
||||
* to each element in the original collection.
|
||||
*/
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
public inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {
|
||||
return mapTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)
|
||||
}
|
||||
@@ -1173,6 +1177,7 @@ public inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {
|
||||
* Returns a list containing the results of applying the given [transform] function
|
||||
* to each element and its index in the original collection.
|
||||
*/
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
public inline fun <T, R> Iterable<T>.mapIndexed(transform: (Int, T) -> R): List<R> {
|
||||
return mapIndexedTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)
|
||||
}
|
||||
@@ -1805,6 +1810,7 @@ public infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {
|
||||
*/
|
||||
public inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (T, R) -> V): List<V> {
|
||||
val arraySize = other.size
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(collectionSizeOrDefault(10), arraySize))
|
||||
var i = 0
|
||||
for (element in this) {
|
||||
@@ -1827,6 +1833,7 @@ public infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<T, R>> {
|
||||
public inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (T, R) -> V): List<V> {
|
||||
val first = iterator()
|
||||
val second = other.iterator()
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val list = ArrayList<V>(Math.min(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10)))
|
||||
while (first.hasNext() && second.hasNext()) {
|
||||
list.add(transform(first.next(), second.next()))
|
||||
|
||||
@@ -499,7 +499,8 @@ public inline fun String.reversed(): String {
|
||||
* If any of two pairs would have the same key the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> CharSequence.associate(transform: (Char) -> Pair<K, V>): Map<K, V> {
|
||||
val capacity = ((length/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(length).coerceAtLeast(16)
|
||||
return associateTo(LinkedHashMap<K, V>(capacity), transform)
|
||||
}
|
||||
|
||||
@@ -509,7 +510,8 @@ public inline fun <K, V> CharSequence.associate(transform: (Char) -> Pair<K, V>)
|
||||
* If any two characters would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K> CharSequence.associateBy(keySelector: (Char) -> K): Map<K, Char> {
|
||||
val capacity = ((length/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(length).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, Char>(capacity), keySelector)
|
||||
}
|
||||
|
||||
@@ -518,7 +520,8 @@ public inline fun <K> CharSequence.associateBy(keySelector: (Char) -> K): Map<K,
|
||||
* If any two characters would have the same key returned by [keySelector] the last one gets added to the map.
|
||||
*/
|
||||
public inline fun <K, V> CharSequence.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map<K, V> {
|
||||
val capacity = ((length/.75f) + 1).toInt().coerceAtLeast(16)
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
val capacity = mapCapacity(length).coerceAtLeast(16)
|
||||
return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)
|
||||
}
|
||||
|
||||
|
||||
@@ -135,13 +135,14 @@ public inline fun <T> Enumeration<T>.toList(): List<T> = Collections.list(this)
|
||||
/**
|
||||
* Returns the size of this iterable if it is known, or `null` otherwise.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Iterable<T>.collectionSizeOrNull(): Int? = if (this is Collection<*>) this.size else null
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun <T> Iterable<T>.collectionSizeOrNull(): Int? = if (this is Collection<*>) this.size else null
|
||||
|
||||
/**
|
||||
* Returns the size of this iterable if it is known, or the specified [default] value otherwise.
|
||||
*/
|
||||
public fun <T> Iterable<T>.collectionSizeOrDefault(default: Int): Int = if (this is Collection<*>) this.size else default
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun <T> Iterable<T>.collectionSizeOrDefault(default: Int): Int = if (this is Collection<*>) this.size else default
|
||||
|
||||
/** Returns true when it's safe to convert this collection to a set without changing contains method behavior. */
|
||||
private fun <T> Collection<T>.safeToConvertToSet() = size > 2 && this is ArrayList
|
||||
|
||||
@@ -12,7 +12,10 @@ import kotlin.internal.Exact
|
||||
*
|
||||
* @throws NoSuchElementException when the map doesn't contain value for the property name and doesn't provide an implicit default (see [withDefault]).
|
||||
*/
|
||||
public operator fun <V, V1: V> Map<in String, @Exact V>.getValue(thisRef: Any?, property: KProperty<*>): V1 = getOrImplicitDefault(property.name) as V1
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
public inline operator fun <V, V1: V> Map<in String, @Exact V>.getValue(thisRef: Any?, property: KProperty<*>): V1
|
||||
= getOrImplicitDefault(property.name) as V1
|
||||
|
||||
/**
|
||||
* Returns the value of the property for the given object from this mutable map.
|
||||
@@ -23,7 +26,10 @@ public operator fun <V, V1: V> Map<in String, @Exact V>.getValue(thisRef: Any?,
|
||||
* @throws NoSuchElementException when the map doesn't contain value for the property name and doesn't provide an implicit default (see [withDefault]).
|
||||
*/
|
||||
@kotlin.jvm.JvmName("getVar")
|
||||
public operator fun <V> MutableMap<in String, in V>.getValue(thisRef: Any?, property: KProperty<*>): V = getOrImplicitDefault(property.name) as V
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
public inline operator fun <V> MutableMap<in String, in V>.getValue(thisRef: Any?, property: KProperty<*>): V
|
||||
= getOrImplicitDefault(property.name) as V
|
||||
|
||||
/**
|
||||
* Stores the value of the property for the given object in this mutable map.
|
||||
@@ -31,6 +37,7 @@ public operator fun <V> MutableMap<in String, in V>.getValue(thisRef: Any?, prop
|
||||
* @param property the metadata for the property, used to get the name of property and store the value associated with that name in the map.
|
||||
* @param value the value to set.
|
||||
*/
|
||||
public operator fun <V> MutableMap<in String, in V>.setValue(thisRef: Any?, property: KProperty<*>, value: V) {
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline operator fun <V> MutableMap<in String, in V>.setValue(thisRef: Any?, property: KProperty<*>, value: V) {
|
||||
this.put(property.name, value)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.*
|
||||
* @throws NoSuchElementException when the map doesn't contain value for the specified key and no implicit default was provided for that map.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("getOrImplicitDefaultNullable")
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun <K, V> Map<K, V>.getOrImplicitDefault(key: K): V {
|
||||
if (this is MapWithDefault)
|
||||
return this.getOrImplicitDefault(key)
|
||||
|
||||
@@ -83,6 +83,7 @@ public fun <K, V> linkedMapOf(vararg pairs: Pair<K, V>): LinkedHashMap<K, V>
|
||||
|
||||
private val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
|
||||
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun mapCapacity(expectedSize: Int): Int {
|
||||
if (expectedSize < 3) {
|
||||
return expectedSize + 1
|
||||
@@ -277,8 +278,9 @@ public fun <K, V> MutableMap<in K, in V>.putAll(pairs: Sequence<Pair<K,V>>): Uni
|
||||
*
|
||||
* @sample test.collections.MapTest.mapValues
|
||||
*/
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
public inline fun <K, V, R> Map<K, V>.mapValues(transform: (Map.Entry<K, V>) -> R): Map<K, R> {
|
||||
return mapValuesTo(LinkedHashMap<K, R>(size), transform)
|
||||
return mapValuesTo(LinkedHashMap<K, R>(mapCapacity(size)), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,8 +289,9 @@ public inline fun <K, V, R> Map<K, V>.mapValues(transform: (Map.Entry<K, V>) ->
|
||||
*
|
||||
* @sample test.collections.MapTest.mapKeys
|
||||
*/
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
public inline fun <K, V, R> Map<K, V>.mapKeys(transform: (Map.Entry<K, V>) -> R): Map<R, V> {
|
||||
return mapKeysTo(LinkedHashMap<R, V>(size), transform)
|
||||
return mapKeysTo(LinkedHashMap<R, V>(mapCapacity(size)), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,7 @@ public inline fun Timer.scheduleAtFixedRate(time: Date, period: Long, crossinlin
|
||||
|
||||
|
||||
// exposed as public
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun timer(name: String?, daemon: Boolean) = if (name == null) Timer(daemon) else Timer(name, daemon)
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,3 +58,10 @@ internal annotation class OnlyInputTypes
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal annotation class InlineOnly
|
||||
|
||||
/**
|
||||
* Specifies that this part of internal API is effectively public exposed by using in public inline function
|
||||
*/
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal annotation class InlineExposed
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package kotlin.jvm.internal.unsafe
|
||||
|
||||
/** @suppress */
|
||||
@Deprecated("This function supports the standard library infrastructure and is not intended to be used directly from user code.", level = DeprecationLevel.ERROR)
|
||||
public fun monitorEnter(monitor: Any): Unit = throw UnsupportedOperationException("This function can only be used privately")
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun monitorEnter(monitor: Any): Unit = throw UnsupportedOperationException("This function can only be used privately")
|
||||
|
||||
/** @suppress */
|
||||
@Deprecated("This function supports the standard library infrastructure and is not intended to be used directly from user code.", level = DeprecationLevel.ERROR)
|
||||
public fun monitorExit(monitor: Any): Unit = throw UnsupportedOperationException("This function can only be used privately")
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun monitorExit(monitor: Any): Unit = throw UnsupportedOperationException("This function can only be used privately")
|
||||
|
||||
@@ -27,4 +27,6 @@ public inline fun String.toRegex(options: Set<RegexOption>): Regex = Regex(this,
|
||||
* Provides the way to use Regex API on the instances of [Pattern].
|
||||
*/
|
||||
@JvmVersion
|
||||
public fun java.util.regex.Pattern.toRegex(): Regex = Regex(this)
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
public inline fun java.util.regex.Pattern.toRegex(): Regex = Regex(this)
|
||||
@@ -91,7 +91,9 @@ public data class MatchGroup(public val value: String, public val range: IntRang
|
||||
*
|
||||
* For pattern syntax reference see [java.util.regex.Pattern]
|
||||
*/
|
||||
public class Regex internal constructor(private val nativePattern: Pattern) {
|
||||
public class Regex
|
||||
@kotlin.internal.InlineExposed
|
||||
internal constructor(private val nativePattern: Pattern) {
|
||||
|
||||
|
||||
/** Creates a regular expression from the specified [pattern] string and the default options. */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@file:kotlin.jvm.JvmName("PreconditionsKt")
|
||||
package kotlin
|
||||
|
||||
|
||||
@kotlin.internal.InlineExposed
|
||||
internal object _Assertions {
|
||||
@JvmField
|
||||
internal val ENABLED: Boolean = javaClass.desiredAssertionStatus()
|
||||
|
||||
@@ -8,14 +8,15 @@ import kotlin.jvm.internal.unsafe.*
|
||||
/**
|
||||
* Executes the given function [block] while holding the monitor of the given object [lock].
|
||||
*/
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R> synchronized(lock: Any, block: () -> R): R {
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
monitorEnter(lock)
|
||||
try {
|
||||
return block()
|
||||
}
|
||||
finally {
|
||||
@Suppress("INVISIBLE_MEMBER_FROM_INLINE")
|
||||
monitorExit(lock)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user