Introduce Common protected function AbstractMutableList.removeRange #KT-57151
This commit is contained in:
committed by
Space Team
parent
f84fa29fef
commit
240a423bed
@@ -13,6 +13,13 @@ package kotlin.collections
|
|||||||
public expect abstract class AbstractMutableList<E> : MutableList<E> {
|
public expect abstract class AbstractMutableList<E> : MutableList<E> {
|
||||||
protected constructor()
|
protected constructor()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
|
||||||
|
*/
|
||||||
|
// TODO: Should be @SinceKotlin("2.0"), see KT-64904
|
||||||
|
@SinceKotlin("1.9")
|
||||||
|
protected open fun removeRange(fromIndex: Int, toIndex: Int): Unit
|
||||||
|
|
||||||
// From List
|
// From List
|
||||||
|
|
||||||
override fun isEmpty(): Boolean
|
override fun isEmpty(): Boolean
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
|
|||||||
/**
|
/**
|
||||||
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
|
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
|
||||||
*/
|
*/
|
||||||
protected open fun removeRange(fromIndex: Int, toIndex: Int) {
|
protected actual open fun removeRange(fromIndex: Int, toIndex: Int) {
|
||||||
val iterator = listIterator(fromIndex)
|
val iterator = listIterator(fromIndex)
|
||||||
repeat(toIndex - fromIndex) {
|
repeat(toIndex - fromIndex) {
|
||||||
iterator.next()
|
iterator.next()
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import java.util.AbstractList
|
|||||||
* @param E the type of elements contained in the list. The list is invariant in its element type.
|
* @param E the type of elements contained in the list. The list is invariant in its element type.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.1")
|
@SinceKotlin("1.1")
|
||||||
|
// removeRange: Kotlin `protected` visibility is different from Java
|
||||||
|
@Suppress("NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS")
|
||||||
public actual abstract class AbstractMutableList<E> protected actual constructor() : MutableList<E>, AbstractList<E>() {
|
public actual abstract class AbstractMutableList<E> protected actual constructor() : MutableList<E>, AbstractList<E>() {
|
||||||
/**
|
/**
|
||||||
* Replaces the element at the specified position in this list with the specified element.
|
* Replaces the element at the specified position in this list with the specified element.
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
|
|||||||
/**
|
/**
|
||||||
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
|
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
|
||||||
*/
|
*/
|
||||||
protected open fun removeRange(fromIndex: Int, toIndex: Int) {
|
protected actual open fun removeRange(fromIndex: Int, toIndex: Int) {
|
||||||
val iterator = listIterator(fromIndex)
|
val iterator = listIterator(fromIndex)
|
||||||
repeat(toIndex - fromIndex) {
|
repeat(toIndex - fromIndex) {
|
||||||
iterator.next()
|
iterator.next()
|
||||||
|
|||||||
Reference in New Issue
Block a user