Add samples for reversed list views

#KT-20357
This commit is contained in:
kenji tomita
2017-11-17 21:38:57 +09:00
committed by Ilya Gorbunov
parent 2fc26ba08f
commit 1db0e5c23e
2 changed files with 62 additions and 0 deletions
@@ -46,12 +46,14 @@ private fun List<*>.reversePositionIndex(index: Int) =
/**
* Returns a reversed read-only view of the original List.
* All changes made in the original list will be reflected in the reversed one.
* @sample samples.collections.ReversedViews.asReversedList
*/
public fun <T> List<T>.asReversed(): List<T> = ReversedListReadOnly(this)
/**
* Returns a reversed mutable view of the original mutable List.
* All changes made in the original list will be reflected in the reversed one and vice versa.
* @sample samples.collections.ReversedViews.asReversedMutableList
*/
@kotlin.jvm.JvmName("asReversedMutable")
public fun <T> MutableList<T>.asReversed(): MutableList<T> = ReversedList(this)