Adjust stdlib to remove/charAt transformation
This commit is contained in:
@@ -18,7 +18,7 @@ public abstract class AbstractCollection<E>() : MutableCollection<E> {
|
|||||||
override fun iterator(): MutableIterator<E> = noImpl
|
override fun iterator(): MutableIterator<E> = noImpl
|
||||||
|
|
||||||
override fun add(e: E): Boolean = noImpl
|
override fun add(e: E): Boolean = noImpl
|
||||||
override fun remove(o: Any?): Boolean = noImpl
|
override fun remove(o: E): Boolean = noImpl
|
||||||
|
|
||||||
override fun addAll(c: Collection<E>): Boolean = noImpl
|
override fun addAll(c: Collection<E>): Boolean = noImpl
|
||||||
override fun containsAll(c: Collection<E>): Boolean = noImpl
|
override fun containsAll(c: Collection<E>): Boolean = noImpl
|
||||||
@@ -41,7 +41,7 @@ public abstract class AbstractList<E>() : AbstractCollection<E>(), MutableList<E
|
|||||||
override fun add(index: Int, element: E): Unit = noImpl
|
override fun add(index: Int, element: E): Unit = noImpl
|
||||||
override fun addAll(index: Int, c: Collection<E>): Boolean = noImpl
|
override fun addAll(index: Int, c: Collection<E>): Boolean = noImpl
|
||||||
|
|
||||||
override fun remove(index: Int): E = noImpl
|
override fun removeAt(index: Int): E = noImpl
|
||||||
|
|
||||||
override fun indexOf(o: Any?): Int = noImpl
|
override fun indexOf(o: Any?): Int = noImpl
|
||||||
override fun lastIndexOf(o: Any?): Int = noImpl
|
override fun lastIndexOf(o: Any?): Int = noImpl
|
||||||
|
|||||||
@@ -22,6 +22,15 @@ public fun <K, V> Map.Entry<K, V>.getKey(): K = key
|
|||||||
@Deprecated("Use property `value` instead", ReplaceWith("this.value"))
|
@Deprecated("Use property `value` instead", ReplaceWith("this.value"))
|
||||||
public fun <K, V> Map.Entry<K, V>.getValue(): V = value
|
public fun <K, V> Map.Entry<K, V>.getValue(): V = value
|
||||||
|
|
||||||
|
@Deprecated("Use operator 'get' instead", ReplaceWith("this[index]"))
|
||||||
|
public fun CharSequence.charAt(index: Int): Char = this[index]
|
||||||
|
|
||||||
|
@Deprecated("Use `removeAt` instead", ReplaceWith("this.removeAt(index)"))
|
||||||
|
public fun <E> MutableList<E>.remove(index: Int): E = removeAt(index)
|
||||||
|
|
||||||
|
@Deprecated("Use explicit cast to MutableCollection<Any?> instead", ReplaceWith("(this as MutableCollection<Any?>).remove(o)"))
|
||||||
|
public fun <E> MutableCollection<E>.remove(o: Any?): Boolean = remove(o as E)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified [element] to this mutable collection.
|
* Adds the specified [element] to this mutable collection.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ private open class ReversedListReadOnly<T>(protected open val delegate: List<T>)
|
|||||||
|
|
||||||
private class ReversedList<T>(protected override val delegate: MutableList<T>) : ReversedListReadOnly<T>(delegate) {
|
private class ReversedList<T>(protected override val delegate: MutableList<T>) : ReversedListReadOnly<T>(delegate) {
|
||||||
override fun clear() = delegate.clear()
|
override fun clear() = delegate.clear()
|
||||||
override fun remove(index: Int): T = delegate.remove(index.flipIndex())
|
override fun removeAt(index: Int): T = delegate.removeAt(index.flipIndex())
|
||||||
|
|
||||||
override fun set(index: Int, element: T): T = delegate.set(index.flipIndex(), element)
|
override fun set(index: Int, element: T): T = delegate.set(index.flipIndex(), element)
|
||||||
override fun add(index: Int, element: T) {
|
override fun add(index: Int, element: T) {
|
||||||
|
|||||||
@@ -191,15 +191,6 @@ public val String.indices: IntRange
|
|||||||
public val String.lastIndex: Int
|
public val String.lastIndex: Int
|
||||||
get() = this.length() - 1
|
get() = this.length() - 1
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a character at the given index in a [CharSequence]. Allows to use the
|
|
||||||
* index operator for working with character sequences:
|
|
||||||
* ```
|
|
||||||
* val c = charSequence[5]
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
public operator fun CharSequence.get(index: Int): Char = this.charAt(index)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns `true` if this CharSequence has Unicode surrogate pair at the specified [index].
|
* Returns `true` if this CharSequence has Unicode surrogate pair at the specified [index].
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -157,11 +157,11 @@ class ReversedViewsTest {
|
|||||||
val original = arrayListOf(1, 2, 3, 4)
|
val original = arrayListOf(1, 2, 3, 4)
|
||||||
val reversed = original.asReversed()
|
val reversed = original.asReversed()
|
||||||
|
|
||||||
original.remove(3)
|
original.removeAt(3)
|
||||||
assertEquals(listOf(1, 2, 3), original)
|
assertEquals(listOf(1, 2, 3), original)
|
||||||
assertEquals(listOf(3, 2, 1), reversed)
|
assertEquals(listOf(3, 2, 1), reversed)
|
||||||
|
|
||||||
reversed.remove(2)
|
reversed.removeAt(2)
|
||||||
assertEquals(listOf(2, 3), original)
|
assertEquals(listOf(2, 3), original)
|
||||||
assertEquals(listOf(3, 2), reversed)
|
assertEquals(listOf(3, 2), reversed)
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ class ReversedViewsTest {
|
|||||||
|
|
||||||
@test fun testRemoveIOOB() {
|
@test fun testRemoveIOOB() {
|
||||||
val success = try {
|
val success = try {
|
||||||
arrayListOf(1, 2, 3).asReversed().remove(3)
|
arrayListOf(1, 2, 3).asReversed().removeAt(3)
|
||||||
true
|
true
|
||||||
} catch(expected: IndexOutOfBoundsException) {
|
} catch(expected: IndexOutOfBoundsException) {
|
||||||
false
|
false
|
||||||
|
|||||||
Reference in New Issue
Block a user