private -> internal where it's necessary
This commit is contained in:
@@ -5,7 +5,6 @@ package kotlin
|
||||
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.nio.charset.Charset
|
||||
import java.util.Arrays
|
||||
import kotlin.jvm.internal.Intrinsic
|
||||
|
||||
// Array "constructor"
|
||||
@@ -104,6 +103,6 @@ public inline fun <reified T> Collection<T>.toTypedArray(): Array<T> {
|
||||
public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>()
|
||||
|
||||
/** Internal unsafe construction of array based on reference array type */
|
||||
private fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<out T> {
|
||||
internal fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<out T> {
|
||||
return java.lang.reflect.Array.newInstance(reference.javaClass.componentType, size) as Array<out T>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ package kotlin
|
||||
import java.io.Serializable
|
||||
import java.util.*
|
||||
|
||||
private object EmptyIterator : ListIterator<Nothing> {
|
||||
internal object EmptyIterator : ListIterator<Nothing> {
|
||||
override fun hasNext(): Boolean = false
|
||||
override fun hasPrevious(): Boolean = false
|
||||
override fun nextIndex(): Int = 0
|
||||
@@ -15,7 +15,7 @@ private object EmptyIterator : ListIterator<Nothing> {
|
||||
override fun previous(): Nothing = throw NoSuchElementException()
|
||||
}
|
||||
|
||||
private object EmptyList : List<Nothing>, Serializable {
|
||||
internal object EmptyList : List<Nothing>, Serializable {
|
||||
override fun equals(other: Any?): Boolean = other is List<*> && other.isEmpty()
|
||||
override fun hashCode(): Int = 1
|
||||
override fun toString(): String = "[]"
|
||||
@@ -125,7 +125,7 @@ public fun <T> Iterable<T>.collectionSizeOrDefault(default: Int): Int = if (this
|
||||
private fun <T> Collection<T>.safeToConvertToSet() = size() > 2 && this is ArrayList
|
||||
|
||||
/** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */
|
||||
private fun <T> Iterable<T>.convertToSetForSetOperationWith(source: Iterable<T>): Collection<T> =
|
||||
internal fun <T> Iterable<T>.convertToSetForSetOperationWith(source: Iterable<T>): Collection<T> =
|
||||
when(this) {
|
||||
is Set -> this
|
||||
is Collection ->
|
||||
@@ -137,7 +137,7 @@ private fun <T> Iterable<T>.convertToSetForSetOperationWith(source: Iterable<T>)
|
||||
}
|
||||
|
||||
/** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */
|
||||
private fun <T> Iterable<T>.convertToSetForSetOperation(): Collection<T> =
|
||||
internal fun <T> Iterable<T>.convertToSetForSetOperation(): Collection<T> =
|
||||
when(this) {
|
||||
is Set -> this
|
||||
is Collection -> if (this.safeToConvertToSet()) toHashSet() else this
|
||||
|
||||
@@ -79,7 +79,7 @@ public fun <K, V> linkedMapOf(vararg values: Pair<K, V>): LinkedHashMap<K, V> {
|
||||
|
||||
private val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
|
||||
|
||||
private fun mapCapacity(expectedSize: Int): Int {
|
||||
internal fun mapCapacity(expectedSize: Int): Int {
|
||||
if (expectedSize < 3) {
|
||||
return expectedSize + 1
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public fun <T, R> Sequence<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> {
|
||||
* @param sendWhen If `true`, values for which the predicate returns `true` are returned. Otherwise,
|
||||
* values for which the predicate returns `false` are returned
|
||||
*/
|
||||
private class FilteringSequence<T>(private val sequence: Sequence<T>,
|
||||
internal class FilteringSequence<T>(private val sequence: Sequence<T>,
|
||||
private val sendWhen: Boolean = true,
|
||||
private val predicate: (T) -> Boolean
|
||||
) : Sequence<T> {
|
||||
@@ -142,7 +142,7 @@ private class FilteringSequence<T>(private val sequence: Sequence<T>,
|
||||
* in the underlying [sequence].
|
||||
*/
|
||||
|
||||
private class TransformingSequence<T, R>
|
||||
internal class TransformingSequence<T, R>
|
||||
constructor(private val sequence: Sequence<T>, private val transformer: (T) -> R) : Sequence<R> {
|
||||
override fun iterator(): Iterator<R> = object : Iterator<R> {
|
||||
val iterator = sequence.iterator()
|
||||
@@ -161,7 +161,7 @@ constructor(private val sequence: Sequence<T>, private val transformer: (T) -> R
|
||||
* in the underlying [sequence], where the transformer function takes the index of the value in the underlying
|
||||
* sequence along with the value itself.
|
||||
*/
|
||||
private class TransformingIndexedSequence<T, R>
|
||||
internal class TransformingIndexedSequence<T, R>
|
||||
constructor(private val sequence: Sequence<T>, private val transformer: (Int, T) -> R) : Sequence<R> {
|
||||
override fun iterator(): Iterator<R> = object : Iterator<R> {
|
||||
val iterator = sequence.iterator()
|
||||
@@ -180,7 +180,7 @@ constructor(private val sequence: Sequence<T>, private val transformer: (Int, T)
|
||||
* A sequence which combines values from the underlying [sequence] with their indices and returns them as
|
||||
* [IndexedValue] objects.
|
||||
*/
|
||||
private class IndexingSequence<T>
|
||||
internal class IndexingSequence<T>
|
||||
constructor(private val sequence: Sequence<T>) : Sequence<IndexedValue<T>> {
|
||||
override fun iterator(): Iterator<IndexedValue<T>> = object : Iterator<IndexedValue<T>> {
|
||||
val iterator = sequence.iterator()
|
||||
@@ -200,7 +200,7 @@ constructor(private val sequence: Sequence<T>) : Sequence<IndexedValue<T>> {
|
||||
* [transform] function and returns the values returned by that function. The sequence stops returning
|
||||
* values as soon as one of the underlying sequences stops returning values.
|
||||
*/
|
||||
private class MergingSequence<T1, T2, V>
|
||||
internal class MergingSequence<T1, T2, V>
|
||||
constructor(private val sequence1: Sequence<T1>,
|
||||
private val sequence2: Sequence<T2>,
|
||||
private val transform: (T1, T2) -> V
|
||||
@@ -218,7 +218,7 @@ private class MergingSequence<T1, T2, V>
|
||||
}
|
||||
}
|
||||
|
||||
private class FlatteningSequence<T, R>
|
||||
internal class FlatteningSequence<T, R>
|
||||
constructor(private val sequence: Sequence<T>,
|
||||
private val transformer: (T) -> Sequence<R>
|
||||
) : Sequence<R> {
|
||||
@@ -257,7 +257,7 @@ private class FlatteningSequence<T, R>
|
||||
}
|
||||
}
|
||||
|
||||
private class MultiSequence<T>
|
||||
internal class MultiSequence<T>
|
||||
constructor(private val sequence: Sequence<Sequence<T>>) : Sequence<T> {
|
||||
override fun iterator(): Iterator<T> = object : Iterator<T> {
|
||||
val iterator = sequence.iterator()
|
||||
@@ -298,7 +298,7 @@ constructor(private val sequence: Sequence<Sequence<T>>) : Sequence<T> {
|
||||
* A sequence that returns at most [count] values from the underlying [sequence], and stops returning values
|
||||
* as soon as that count is reached.
|
||||
*/
|
||||
private class TakeSequence<T>
|
||||
internal class TakeSequence<T>
|
||||
constructor(private val sequence: Sequence<T>,
|
||||
private val count: Int
|
||||
) : Sequence<T> {
|
||||
@@ -327,7 +327,7 @@ private class TakeSequence<T>
|
||||
* A sequence that returns values from the underlying [sequence] while the [predicate] function returns
|
||||
* `true`, and stops returning values once the function returns `false` for the next element.
|
||||
*/
|
||||
private class TakeWhileSequence<T>
|
||||
internal class TakeWhileSequence<T>
|
||||
constructor(private val sequence: Sequence<T>,
|
||||
private val predicate: (T) -> Boolean
|
||||
) : Sequence<T> {
|
||||
@@ -373,7 +373,7 @@ private class TakeWhileSequence<T>
|
||||
* A sequence that skips the specified number of values from the underlying [sequence] and returns
|
||||
* all values after that.
|
||||
*/
|
||||
private class DropSequence<T>
|
||||
internal class DropSequence<T>
|
||||
constructor(private val sequence: Sequence<T>,
|
||||
private val count: Int
|
||||
) : Sequence<T> {
|
||||
@@ -409,7 +409,7 @@ private class DropSequence<T>
|
||||
* A sequence that skips the values from the underlying [sequence] while the given [predicate] returns `true` and returns
|
||||
* all values after that.
|
||||
*/
|
||||
private class DropWhileSequence<T>
|
||||
internal class DropWhileSequence<T>
|
||||
constructor(private val sequence: Sequence<T>,
|
||||
private val predicate: (T) -> Boolean
|
||||
) : Sequence<T> {
|
||||
@@ -452,7 +452,7 @@ private class DropWhileSequence<T>
|
||||
}
|
||||
}
|
||||
|
||||
private class DistinctSequence<T, K>(private val source : Sequence<T>, private val keySelector : (T) -> K) : Sequence<T> {
|
||||
internal class DistinctSequence<T, K>(private val source : Sequence<T>, private val keySelector : (T) -> K) : Sequence<T> {
|
||||
override fun iterator(): Iterator<T> = DistinctIterator(source.iterator(), keySelector)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ package kotlin
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
|
||||
private class ConstrainedOnceSequence<T>(sequence: Sequence<T>) : Sequence<T> {
|
||||
internal class ConstrainedOnceSequence<T>(sequence: Sequence<T>) : Sequence<T> {
|
||||
private val sequenceRef = AtomicReference(sequence)
|
||||
|
||||
override fun iterator(): Iterator<T> {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.Serializable
|
||||
import java.util.*
|
||||
|
||||
|
||||
private object EmptySet : Set<Nothing>, Serializable {
|
||||
internal object EmptySet : Set<Nothing>, Serializable {
|
||||
override fun equals(other: Any?): Boolean = other is Set<*> && other.isEmpty()
|
||||
override fun hashCode(): Int = 0
|
||||
override fun toString(): String = "[]"
|
||||
@@ -59,4 +59,4 @@ public fun sortedSetOf<T>(vararg values: T): TreeSet<T> = values.toCollection(Tr
|
||||
* Returns a new [SortedSet] with the given [comparator] and elements.
|
||||
*/
|
||||
@JvmVersion
|
||||
public fun sortedSetOf<T>(comparator: Comparator<in T>, vararg values: T): TreeSet<T> = values.toCollection(TreeSet<T>(comparator))
|
||||
public fun sortedSetOf<T>(comparator: Comparator<in T>, vararg values: T): TreeSet<T> = values.toCollection(TreeSet<T>(comparator))
|
||||
|
||||
@@ -14,22 +14,22 @@ import kotlin.text.Regex
|
||||
/**
|
||||
* Returns the index within this string of the first occurrence of the specified character, starting from the specified offset.
|
||||
*/
|
||||
private fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toInt(), fromIndex)
|
||||
internal fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toInt(), fromIndex)
|
||||
|
||||
/**
|
||||
* Returns the index within this string of the first occurrence of the specified substring, starting from the specified offset.
|
||||
*/
|
||||
private fun String.nativeIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex)
|
||||
internal fun String.nativeIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex)
|
||||
|
||||
/**
|
||||
* Returns the index within this string of the last occurrence of the specified character.
|
||||
*/
|
||||
private fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toInt(), fromIndex)
|
||||
internal fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toInt(), fromIndex)
|
||||
|
||||
/**
|
||||
* Returns the index within this string of the last occurrence of the specified character, starting from the specified offset.
|
||||
*/
|
||||
private fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex)
|
||||
internal fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex)
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,7 +54,7 @@ public enum class LazyThreadSafetyMode {
|
||||
|
||||
private object UNINITIALIZED_VALUE
|
||||
|
||||
private open class LazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializable {
|
||||
internal open class LazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializable {
|
||||
private var initializer: (() -> T)? = initializer
|
||||
@Volatile private var _value: Any? = UNINITIALIZED_VALUE
|
||||
protected open val lock: Any
|
||||
@@ -88,9 +88,9 @@ private open class LazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializab
|
||||
private fun writeReplace(): Any = InitializedLazyImpl(value)
|
||||
}
|
||||
|
||||
private class ExternallySynchronizedLazyImpl<out T>(override val lock: Any, initializer: () -> T): LazyImpl<T>(initializer)
|
||||
internal class ExternallySynchronizedLazyImpl<out T>(override val lock: Any, initializer: () -> T): LazyImpl<T>(initializer)
|
||||
|
||||
private class UnsafeLazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializable {
|
||||
internal class UnsafeLazyImpl<out T>(initializer: () -> T) : Lazy<T>(), Serializable {
|
||||
private var initializer: (() -> T)? = initializer
|
||||
private var _value: Any? = UNINITIALIZED_VALUE
|
||||
|
||||
|
||||
@@ -32,6 +32,6 @@ public fun <T: Comparable<T>> T.rangeTo(that: T): ComparableRange<T> {
|
||||
}
|
||||
|
||||
|
||||
private fun checkStepIsPositive(isPositive: Boolean, step: Number) {
|
||||
internal fun checkStepIsPositive(isPositive: Boolean, step: Number) {
|
||||
if (!isPositive) throw IllegalArgumentException("Step must be positive, was: $step")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user