windowed function: add default parameters, drop or keep partial windows, KEEP-11
Make step default to 1. Add partialWindows boolean parameter defaulting to false to control whether to keep partial windows in the end.
This commit is contained in:
@@ -1799,7 +1799,7 @@ public fun <T : Any> List<T?>.requireNoNulls(): List<T> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {
|
public fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {
|
||||||
return windowed(size, size)
|
return windowed(size, size, partialWindows = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1818,7 +1818,7 @@ public fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T, R> Iterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R> {
|
public fun <T, R> Iterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R> {
|
||||||
return windowed(size, size, transform)
|
return windowed(size, size, partialWindows = true, transform = transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2011,25 +2011,29 @@ public inline fun <T> Collection<T>.plusElement(element: T): List<T> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Iterable<T>.windowed(size: Int, step: Int): List<List<T>> {
|
public fun <T> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<List<T>> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
if (this is RandomAccess && this is List) {
|
if (this is RandomAccess && this is List) {
|
||||||
val thisSize = this.size
|
val thisSize = this.size
|
||||||
val result = ArrayList<List<T>>((thisSize + step - 1) / step)
|
val result = ArrayList<List<T>>((thisSize + step - 1) / step)
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
result.add(List(size.coerceAtMost(thisSize - index)) { this[it + index] })
|
val windowSize = size.coerceAtMost(thisSize - index)
|
||||||
|
if (windowSize < size && !partialWindows) break
|
||||||
|
result.add(List(windowSize) { this[it + index] })
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
val result = ArrayList<List<T>>()
|
val result = ArrayList<List<T>>()
|
||||||
windowedIterator(iterator(), size, step, dropTrailing = false, reuseBuffer = false).forEach {
|
windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = false).forEach {
|
||||||
result.add(it)
|
result.add(it)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -2046,12 +2050,14 @@ public fun <T> Iterable<T>.windowed(size: Int, step: Int): List<List<T>> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T, R> Iterable<T>.windowed(size: Int, step: Int, transform: (List<T>) -> R): List<R> {
|
public fun <T, R> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): List<R> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
if (this is RandomAccess && this is List) {
|
if (this is RandomAccess && this is List) {
|
||||||
val thisSize = this.size
|
val thisSize = this.size
|
||||||
@@ -2060,13 +2066,14 @@ public fun <T, R> Iterable<T>.windowed(size: Int, step: Int, transform: (List<T>
|
|||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
window.move(index, (index + size).coerceAtMost(thisSize))
|
window.move(index, (index + size).coerceAtMost(thisSize))
|
||||||
|
if (!partialWindows && window.size < size) break
|
||||||
result.add(transform(window))
|
result.add(transform(window))
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
val result = ArrayList<R>()
|
val result = ArrayList<R>()
|
||||||
windowedIterator(iterator(), size, step, dropTrailing = false, reuseBuffer = true).forEach {
|
windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = true).forEach {
|
||||||
result.add(transform(it))
|
result.add(transform(it))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -1322,7 +1322,7 @@ public fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> {
|
public fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> {
|
||||||
return windowed(size, size)
|
return windowed(size, size, partialWindows = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1343,7 +1343,7 @@ public fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T, R> Sequence<T>.chunked(size: Int, transform: (List<T>) -> R): Sequence<R> {
|
public fun <T, R> Sequence<T>.chunked(size: Int, transform: (List<T>) -> R): Sequence<R> {
|
||||||
return windowed(size, size, transform)
|
return windowed(size, size, partialWindows = true, transform = transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1524,13 +1524,15 @@ public inline fun <T> Sequence<T>.plusElement(element: T): Sequence<T> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Sequence<T>.windowed(size: Int, step: Int): Sequence<List<T>> {
|
public fun <T> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): Sequence<List<T>> {
|
||||||
return windowedSequence(size, step, dropTrailing = false, reuseBuffer = false)
|
return windowedSequence(size, step, partialWindows, reuseBuffer = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1544,13 +1546,15 @@ public fun <T> Sequence<T>.windowed(size: Int, step: Int): Sequence<List<T>> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T, R> Sequence<T>.windowed(size: Int, step: Int, transform: (List<T>) -> R): Sequence<R> {
|
public fun <T, R> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): Sequence<R> {
|
||||||
return windowedSequence(size, step, dropTrailing = false, reuseBuffer = true).map(transform)
|
return windowedSequence(size, step, partialWindows, reuseBuffer = true).map(transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1113,7 +1113,7 @@ public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun CharSequence.chunked(size: Int): List<String> {
|
public fun CharSequence.chunked(size: Int): List<String> {
|
||||||
return windowed(size, size)
|
return windowed(size, size, partialWindows = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1132,7 +1132,7 @@ public fun CharSequence.chunked(size: Int): List<String> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <R> CharSequence.chunked(size: Int, transform: (CharSequence) -> R): List<R> {
|
public fun <R> CharSequence.chunked(size: Int, transform: (CharSequence) -> R): List<R> {
|
||||||
return windowed(size, size, transform)
|
return windowed(size, size, partialWindows = true, transform = transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1165,7 +1165,7 @@ public fun CharSequence.chunkedSequence(size: Int): Sequence<String> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <R> CharSequence.chunkedSequence(size: Int, transform: (CharSequence) -> R): Sequence<R> {
|
public fun <R> CharSequence.chunkedSequence(size: Int, transform: (CharSequence) -> R): Sequence<R> {
|
||||||
return windowedSequence(size, size, transform)
|
return windowedSequence(size, size, partialWindows = true, transform = transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use zipWithNext instead", ReplaceWith("zipWithNext()"))
|
@Deprecated("Use zipWithNext instead", ReplaceWith("zipWithNext()"))
|
||||||
@@ -1225,13 +1225,15 @@ public inline fun String.partition(predicate: (Char) -> Boolean): Pair<String, S
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun CharSequence.windowed(size: Int, step: Int): List<String> {
|
public fun CharSequence.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<String> {
|
||||||
return windowed(size, step) { it.toString() }
|
return windowed(size, step, partialWindows) { it.toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1245,18 +1247,22 @@ public fun CharSequence.windowed(size: Int, step: Int): List<String> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <R> CharSequence.windowed(size: Int, step: Int, transform: (CharSequence) -> R): List<R> {
|
public fun <R> CharSequence.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R): List<R> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
val thisSize = this.length
|
val thisSize = this.length
|
||||||
val result = ArrayList<R>((thisSize + step - 1) / step)
|
val result = ArrayList<R>((thisSize + step - 1) / step)
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
result.add(transform(subSequence(index, (index + size).coerceAtMost(thisSize))))
|
val end = index + size
|
||||||
|
val coercedEnd = if (end > thisSize) { if (partialWindows) thisSize else break } else end
|
||||||
|
result.add(transform(subSequence(index, coercedEnd)))
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -1271,13 +1277,15 @@ public fun <R> CharSequence.windowed(size: Int, step: Int, transform: (CharSeque
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun CharSequence.windowedSequence(size: Int, step: Int): Sequence<String> {
|
public fun CharSequence.windowedSequence(size: Int, step: Int = 1, partialWindows: Boolean = false): Sequence<String> {
|
||||||
return windowedSequence(size, step) { it.toString() }
|
return windowedSequence(size, step, partialWindows) { it.toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1291,14 +1299,17 @@ public fun CharSequence.windowedSequence(size: Int, step: Int): Sequence<String>
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <R> CharSequence.windowedSequence(size: Int, step: Int, transform: (CharSequence) -> R): Sequence<R> {
|
public fun <R> CharSequence.windowedSequence(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R): Sequence<R> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
return (indices step step).asSequence().map { index -> transform(subSequence(index, (index + size).coerceAtMost(length))) }
|
val windows = (if (partialWindows) indices else 0 until length - size + 1) step step
|
||||||
|
return windows.asSequence().map { index -> transform(subSequence(index, (index + size).coerceAtMost(length))) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1029,12 +1029,33 @@ public expect inline fun <T> Collection<T>.plusElement(element: T): List<T>
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public expect fun <T> Iterable<T>.windowed(size: Int, step: Int): List<List<T>>
|
public fun <T> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<List<T>> {
|
||||||
|
checkWindowSizeStep(size, step)
|
||||||
|
if (this is RandomAccess && this is List) {
|
||||||
|
val thisSize = this.size
|
||||||
|
val result = ArrayList<List<T>>((thisSize + step - 1) / step)
|
||||||
|
var index = 0
|
||||||
|
while (index < thisSize) {
|
||||||
|
val windowSize = size.coerceAtMost(thisSize - index)
|
||||||
|
if (windowSize < size && !partialWindows) break
|
||||||
|
result.add(List(windowSize) { this[it + index] })
|
||||||
|
index += step
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
val result = ArrayList<List<T>>()
|
||||||
|
windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = false).forEach {
|
||||||
|
result.add(it)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of results of applying the given [transform] function to
|
* Returns a list of results of applying the given [transform] function to
|
||||||
@@ -1047,12 +1068,34 @@ public expect fun <T> Iterable<T>.windowed(size: Int, step: Int): List<List<T>>
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public expect fun <T, R> Iterable<T>.windowed(size: Int, step: Int, transform: (List<T>) -> R): List<R>
|
public fun <T, R> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): List<R> {
|
||||||
|
checkWindowSizeStep(size, step)
|
||||||
|
if (this is RandomAccess && this is List) {
|
||||||
|
val thisSize = this.size
|
||||||
|
val result = ArrayList<R>((thisSize + step - 1) / step)
|
||||||
|
val window = MovingSubList(this)
|
||||||
|
var index = 0
|
||||||
|
while (index < thisSize) {
|
||||||
|
window.move(index, (index + size).coerceAtMost(thisSize))
|
||||||
|
if (!partialWindows && window.size < size) break
|
||||||
|
result.add(transform(window))
|
||||||
|
index += step
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
val result = ArrayList<R>()
|
||||||
|
windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = true).forEach {
|
||||||
|
result.add(transform(it))
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection.
|
* Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection.
|
||||||
|
|||||||
@@ -952,12 +952,16 @@ public expect inline fun <T> Sequence<T>.plusElement(element: T): Sequence<T>
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public expect fun <T> Sequence<T>.windowed(size: Int, step: Int): Sequence<List<T>>
|
public fun <T> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): Sequence<List<T>> {
|
||||||
|
return windowedSequence(size, step, partialWindows, reuseBuffer = false)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a sequence of results of applying the given [transform] function to
|
* Returns a sequence of results of applying the given [transform] function to
|
||||||
@@ -970,12 +974,16 @@ public expect fun <T> Sequence<T>.windowed(size: Int, step: Int): Sequence<List<
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public expect fun <T, R> Sequence<T>.windowed(size: Int, step: Int, transform: (List<T>) -> R): Sequence<R>
|
public fun <T, R> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): Sequence<R> {
|
||||||
|
return windowedSequence(size, step, partialWindows, reuseBuffer = true).map(transform)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a sequence of pairs built from elements of both sequences with same indexes.
|
* Returns a sequence of pairs built from elements of both sequences with same indexes.
|
||||||
|
|||||||
@@ -727,12 +727,16 @@ public expect inline fun String.partition(predicate: (Char) -> Boolean): Pair<St
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public expect fun CharSequence.windowed(size: Int, step: Int): List<String>
|
public fun CharSequence.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<String> {
|
||||||
|
return windowed(size, step, partialWindows) { it.toString() }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of results of applying the given [transform] function to
|
* Returns a list of results of applying the given [transform] function to
|
||||||
@@ -745,12 +749,26 @@ public expect fun CharSequence.windowed(size: Int, step: Int): List<String>
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public expect fun <R> CharSequence.windowed(size: Int, step: Int, transform: (CharSequence) -> R): List<R>
|
public fun <R> CharSequence.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R): List<R> {
|
||||||
|
checkWindowSizeStep(size, step)
|
||||||
|
val thisSize = this.length
|
||||||
|
val result = ArrayList<R>((thisSize + step - 1) / step)
|
||||||
|
var index = 0
|
||||||
|
while (index < thisSize) {
|
||||||
|
val end = index + size
|
||||||
|
val coercedEnd = if (end > thisSize) { if (partialWindows) thisSize else break } else end
|
||||||
|
result.add(transform(subSequence(index, coercedEnd)))
|
||||||
|
index += step
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a sequence of snapshots of the window of the given [size]
|
* Returns a sequence of snapshots of the window of the given [size]
|
||||||
@@ -761,12 +779,16 @@ public expect fun <R> CharSequence.windowed(size: Int, step: Int, transform: (Ch
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public expect fun CharSequence.windowedSequence(size: Int, step: Int): Sequence<String>
|
public fun CharSequence.windowedSequence(size: Int, step: Int = 1, partialWindows: Boolean = false): Sequence<String> {
|
||||||
|
return windowedSequence(size, step, partialWindows) { it.toString() }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a sequence of results of applying the given [transform] function to
|
* Returns a sequence of results of applying the given [transform] function to
|
||||||
@@ -779,12 +801,18 @@ public expect fun CharSequence.windowedSequence(size: Int, step: Int): Sequence<
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public expect fun <R> CharSequence.windowedSequence(size: Int, step: Int, transform: (CharSequence) -> R): Sequence<R>
|
public fun <R> CharSequence.windowedSequence(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R): Sequence<R> {
|
||||||
|
checkWindowSizeStep(size, step)
|
||||||
|
val windows = (if (partialWindows) indices else 0 until length - size + 1) step step
|
||||||
|
return windows.asSequence().map { index -> transform(subSequence(index, (index + size).coerceAtMost(length))) }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of pairs built from characters of both char sequences with same indexes. List has length of shortest char sequence.
|
* Returns a list of pairs built from characters of both char sequences with same indexes. List has length of shortest char sequence.
|
||||||
|
|||||||
@@ -153,7 +153,10 @@ class Sequences {
|
|||||||
val moreSparseWindows = sequence.windowed(size = 5, step = 3)
|
val moreSparseWindows = sequence.windowed(size = 5, step = 3)
|
||||||
assertPrints(moreSparseWindows.take(4).toList(), "[[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14]]")
|
assertPrints(moreSparseWindows.take(4).toList(), "[[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14]]")
|
||||||
|
|
||||||
val partialWindows = sequence.take(10).windowed(size = 5, step = 3)
|
val fullWindows = sequence.take(10).windowed(size = 5, step = 3)
|
||||||
|
assertPrints(fullWindows.toList(), "[[1, 2, 3, 4, 5], [4, 5, 6, 7, 8]]")
|
||||||
|
|
||||||
|
val partialWindows = sequence.take(10).windowed(size = 5, step = 3, partialWindows = true)
|
||||||
assertPrints(partialWindows.toList(), "[[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10], [10]]")
|
assertPrints(partialWindows.toList(), "[[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10], [10]]")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,10 +164,10 @@ class Sequences {
|
|||||||
fun averageWindows() {
|
fun averageWindows() {
|
||||||
val dataPoints = sequenceOf(10, 15, 18, 25, 19, 21, 14, 8, 5)
|
val dataPoints = sequenceOf(10, 15, 18, 25, 19, 21, 14, 8, 5)
|
||||||
|
|
||||||
val averaged = dataPoints.windowed(size = 4, step = 1) { window -> window.average() }
|
val averaged = dataPoints.windowed(size = 4, step = 1, partialWindows = true) { window -> window.average() }
|
||||||
assertPrints(averaged.toList(), "[17.0, 19.25, 20.75, 19.75, 15.5, 12.0, 9.0, 6.5, 5.0]")
|
assertPrints(averaged.toList(), "[17.0, 19.25, 20.75, 19.75, 15.5, 12.0, 9.0, 6.5, 5.0]")
|
||||||
|
|
||||||
val averagedNoPartialWindows = dataPoints.windowed(size = 4, step = 1).filter { it.size == 4 }.map { it.average() }
|
val averagedNoPartialWindows = dataPoints.windowed(size = 4, step = 1).map { it.average() }
|
||||||
assertPrints(averagedNoPartialWindows.toList(), "[17.0, 19.25, 20.75, 19.75, 15.5, 12.0]")
|
assertPrints(averagedNoPartialWindows.toList(), "[17.0, 19.25, 20.75, 19.75, 15.5, 12.0]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1809,7 +1809,7 @@ public fun <T : Any> List<T?>.requireNoNulls(): List<T> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {
|
public fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {
|
||||||
return windowed(size, size)
|
return windowed(size, size, partialWindows = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1828,7 +1828,7 @@ public fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T, R> Iterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R> {
|
public fun <T, R> Iterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R> {
|
||||||
return windowed(size, size, transform)
|
return windowed(size, size, partialWindows = true, transform = transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2021,25 +2021,29 @@ public inline fun <T> Collection<T>.plusElement(element: T): List<T> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Iterable<T>.windowed(size: Int, step: Int): List<List<T>> {
|
public fun <T> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<List<T>> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
if (this is RandomAccess && this is List) {
|
if (this is RandomAccess && this is List) {
|
||||||
val thisSize = this.size
|
val thisSize = this.size
|
||||||
val result = ArrayList<List<T>>((thisSize + step - 1) / step)
|
val result = ArrayList<List<T>>((thisSize + step - 1) / step)
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
result.add(List(size.coerceAtMost(thisSize - index)) { this[it + index] })
|
val windowSize = size.coerceAtMost(thisSize - index)
|
||||||
|
if (windowSize < size && !partialWindows) break
|
||||||
|
result.add(List(windowSize) { this[it + index] })
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
val result = ArrayList<List<T>>()
|
val result = ArrayList<List<T>>()
|
||||||
windowedIterator(iterator(), size, step, dropTrailing = false, reuseBuffer = false).forEach {
|
windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = false).forEach {
|
||||||
result.add(it)
|
result.add(it)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -2056,12 +2060,14 @@ public fun <T> Iterable<T>.windowed(size: Int, step: Int): List<List<T>> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this collection.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T, R> Iterable<T>.windowed(size: Int, step: Int, transform: (List<T>) -> R): List<R> {
|
public fun <T, R> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): List<R> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
if (this is RandomAccess && this is List) {
|
if (this is RandomAccess && this is List) {
|
||||||
val thisSize = this.size
|
val thisSize = this.size
|
||||||
@@ -2070,13 +2076,14 @@ public fun <T, R> Iterable<T>.windowed(size: Int, step: Int, transform: (List<T>
|
|||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
window.move(index, (index + size).coerceAtMost(thisSize))
|
window.move(index, (index + size).coerceAtMost(thisSize))
|
||||||
|
if (!partialWindows && window.size < size) break
|
||||||
result.add(transform(window))
|
result.add(transform(window))
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
val result = ArrayList<R>()
|
val result = ArrayList<R>()
|
||||||
windowedIterator(iterator(), size, step, dropTrailing = false, reuseBuffer = true).forEach {
|
windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = true).forEach {
|
||||||
result.add(transform(it))
|
result.add(transform(it))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -1344,7 +1344,7 @@ public fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> {
|
public fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> {
|
||||||
return windowed(size, size)
|
return windowed(size, size, partialWindows = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1365,7 +1365,7 @@ public fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T, R> Sequence<T>.chunked(size: Int, transform: (List<T>) -> R): Sequence<R> {
|
public fun <T, R> Sequence<T>.chunked(size: Int, transform: (List<T>) -> R): Sequence<R> {
|
||||||
return windowed(size, size, transform)
|
return windowed(size, size, partialWindows = true, transform = transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1546,13 +1546,15 @@ public inline fun <T> Sequence<T>.plusElement(element: T): Sequence<T> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Sequence<T>.windowed(size: Int, step: Int): Sequence<List<T>> {
|
public fun <T> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): Sequence<List<T>> {
|
||||||
return windowedSequence(size, step, dropTrailing = false, reuseBuffer = false)
|
return windowedSequence(size, step, partialWindows, reuseBuffer = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1566,13 +1568,15 @@ public fun <T> Sequence<T>.windowed(size: Int, step: Int): Sequence<List<T>> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T, R> Sequence<T>.windowed(size: Int, step: Int, transform: (List<T>) -> R): Sequence<R> {
|
public fun <T, R> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): Sequence<R> {
|
||||||
return windowedSequence(size, step, dropTrailing = false, reuseBuffer = true).map(transform)
|
return windowedSequence(size, step, partialWindows, reuseBuffer = true).map(transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1121,7 +1121,7 @@ public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun CharSequence.chunked(size: Int): List<String> {
|
public fun CharSequence.chunked(size: Int): List<String> {
|
||||||
return windowed(size, size)
|
return windowed(size, size, partialWindows = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1140,7 +1140,7 @@ public fun CharSequence.chunked(size: Int): List<String> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <R> CharSequence.chunked(size: Int, transform: (CharSequence) -> R): List<R> {
|
public fun <R> CharSequence.chunked(size: Int, transform: (CharSequence) -> R): List<R> {
|
||||||
return windowed(size, size, transform)
|
return windowed(size, size, partialWindows = true, transform = transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1173,7 +1173,7 @@ public fun CharSequence.chunkedSequence(size: Int): Sequence<String> {
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <R> CharSequence.chunkedSequence(size: Int, transform: (CharSequence) -> R): Sequence<R> {
|
public fun <R> CharSequence.chunkedSequence(size: Int, transform: (CharSequence) -> R): Sequence<R> {
|
||||||
return windowedSequence(size, size, transform)
|
return windowedSequence(size, size, partialWindows = true, transform = transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use zipWithNext instead", ReplaceWith("zipWithNext()"))
|
@Deprecated("Use zipWithNext instead", ReplaceWith("zipWithNext()"))
|
||||||
@@ -1233,13 +1233,15 @@ public inline fun String.partition(predicate: (Char) -> Boolean): Pair<String, S
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun CharSequence.windowed(size: Int, step: Int): List<String> {
|
public fun CharSequence.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<String> {
|
||||||
return windowed(size, step) { it.toString() }
|
return windowed(size, step, partialWindows) { it.toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1253,18 +1255,22 @@ public fun CharSequence.windowed(size: Int, step: Int): List<String> {
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <R> CharSequence.windowed(size: Int, step: Int, transform: (CharSequence) -> R): List<R> {
|
public fun <R> CharSequence.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R): List<R> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
val thisSize = this.length
|
val thisSize = this.length
|
||||||
val result = ArrayList<R>((thisSize + step - 1) / step)
|
val result = ArrayList<R>((thisSize + step - 1) / step)
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
result.add(transform(subSequence(index, (index + size).coerceAtMost(thisSize))))
|
val end = index + size
|
||||||
|
val coercedEnd = if (end > thisSize) { if (partialWindows) thisSize else break } else end
|
||||||
|
result.add(transform(subSequence(index, coercedEnd)))
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -1279,13 +1285,15 @@ public fun <R> CharSequence.windowed(size: Int, step: Int, transform: (CharSeque
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.takeWindows
|
* @sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun CharSequence.windowedSequence(size: Int, step: Int): Sequence<String> {
|
public fun CharSequence.windowedSequence(size: Int, step: Int = 1, partialWindows: Boolean = false): Sequence<String> {
|
||||||
return windowedSequence(size, step) { it.toString() }
|
return windowedSequence(size, step, partialWindows) { it.toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1299,14 +1307,17 @@ public fun CharSequence.windowedSequence(size: Int, step: Int): Sequence<String>
|
|||||||
*
|
*
|
||||||
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
* Both [size] and [step] must be positive and can be greater than the number of elements in this char sequence.
|
||||||
* @param size the number of elements to take in each window
|
* @param size the number of elements to take in each window
|
||||||
* @param step the number of elements to move the window forward by on an each step
|
* @param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
* @param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
* by default `false` which means partial windows won't be preserved
|
||||||
*
|
*
|
||||||
* @sample samples.collections.Sequences.Transformations.averageWindows
|
* @sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <R> CharSequence.windowedSequence(size: Int, step: Int, transform: (CharSequence) -> R): Sequence<R> {
|
public fun <R> CharSequence.windowedSequence(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R): Sequence<R> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
return (indices step step).asSequence().map { index -> transform(subSequence(index, (index + size).coerceAtMost(length))) }
|
val windows = (if (partialWindows) indices else 0 until length - size + 1) step step
|
||||||
|
return windows.asSequence().map { index -> transform(subSequence(index, (index + size).coerceAtMost(length))) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ internal fun checkWindowSizeStep(size: Int, step: Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun <T> Sequence<T>.windowedSequence(size: Int, step: Int, dropTrailing: Boolean, reuseBuffer: Boolean): Sequence<List<T>> {
|
internal fun <T> Sequence<T>.windowedSequence(size: Int, step: Int, partialWindows: Boolean, reuseBuffer: Boolean): Sequence<List<T>> {
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
return Sequence { windowedIterator(iterator(), size, step, dropTrailing, reuseBuffer) }
|
return Sequence { windowedIterator(iterator(), size, step, partialWindows, reuseBuffer) }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun <T> windowedIterator(iterator: Iterator<T>, size: Int, step: Int, dropTrailing: Boolean, reuseBuffer: Boolean): Iterator<List<T>> {
|
internal fun <T> windowedIterator(iterator: Iterator<T>, size: Int, step: Int, partialWindows: Boolean, reuseBuffer: Boolean): Iterator<List<T>> {
|
||||||
if (!iterator.hasNext()) return EmptyIterator
|
if (!iterator.hasNext()) return EmptyIterator
|
||||||
return buildIterator<List<T>> {
|
return buildIterator<List<T>> {
|
||||||
val gap = step - size
|
val gap = step - size
|
||||||
@@ -49,7 +49,7 @@ internal fun <T> windowedIterator(iterator: Iterator<T>, size: Int, step: Int, d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (buffer.isNotEmpty()) {
|
if (buffer.isNotEmpty()) {
|
||||||
if (!dropTrailing || buffer.size == size) yield(buffer)
|
if (partialWindows || buffer.size == size) yield(buffer)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val buffer = RingBuffer<T>(size)
|
val buffer = RingBuffer<T>(size)
|
||||||
@@ -60,7 +60,7 @@ internal fun <T> windowedIterator(iterator: Iterator<T>, size: Int, step: Int, d
|
|||||||
buffer.removeFirst(step)
|
buffer.removeFirst(step)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!dropTrailing) {
|
if (partialWindows) {
|
||||||
while (buffer.size > step) {
|
while (buffer.size > step) {
|
||||||
yield(if (reuseBuffer) buffer else ArrayList(buffer))
|
yield(if (reuseBuffer) buffer else ArrayList(buffer))
|
||||||
buffer.removeFirst(step)
|
buffer.removeFirst(step)
|
||||||
|
|||||||
@@ -167,23 +167,36 @@ abstract class OrderedIterableTests<T : Iterable<String>>(createFrom: (Array<out
|
|||||||
val size = 7
|
val size = 7
|
||||||
val data = createFrom(Array(size) { "$it" })
|
val data = createFrom(Array(size) { "$it" })
|
||||||
val result = data.windowed(4, 2)
|
val result = data.windowed(4, 2)
|
||||||
|
assertEquals(listOf(
|
||||||
|
listOf("0", "1", "2", "3"),
|
||||||
|
listOf("2", "3", "4", "5")
|
||||||
|
), result)
|
||||||
|
|
||||||
|
val resultPartial = data.windowed(4, 2, partialWindows = true)
|
||||||
assertEquals(listOf(
|
assertEquals(listOf(
|
||||||
listOf("0", "1", "2", "3"),
|
listOf("0", "1", "2", "3"),
|
||||||
listOf("2", "3", "4", "5"),
|
listOf("2", "3", "4", "5"),
|
||||||
listOf("4", "5", "6"),
|
listOf("4", "5", "6"),
|
||||||
listOf("6")
|
listOf("6")
|
||||||
), result)
|
), resultPartial)
|
||||||
|
|
||||||
|
|
||||||
val result2 = data.windowed(2, 3) { it.joinToString("") }
|
val result2 = data.windowed(2, 3) { it.joinToString("") }
|
||||||
assertEquals(listOf("01", "34", "6"), result2)
|
assertEquals(listOf("01", "34"), result2)
|
||||||
|
|
||||||
assertEquals(data.chunked(2), data.windowed(2, 2))
|
val result2partial = data.windowed(2, 3, partialWindows = true) { it.joinToString("") }
|
||||||
|
assertEquals(listOf("01", "34", "6"), result2partial)
|
||||||
|
|
||||||
|
assertEquals(data.chunked(2), data.windowed(2, 2, partialWindows = true))
|
||||||
|
|
||||||
assertEquals(data.take(2), data.windowed(2, size).single())
|
assertEquals(data.take(2), data.windowed(2, size).single())
|
||||||
assertEquals(data.take(3), data.windowed(3, size + 3).single())
|
assertEquals(data.take(3), data.windowed(3, size + 3).single())
|
||||||
|
|
||||||
val result3 = data.windowed(size, 1)
|
assertEquals(data.toList(), data.windowed(size, 1).single())
|
||||||
result3.forEachIndexed { index, window ->
|
assertTrue(data.windowed(size + 1, 1).isEmpty())
|
||||||
|
|
||||||
|
val result3partial = data.windowed(size, 1, partialWindows = true)
|
||||||
|
result3partial.forEachIndexed { index, window ->
|
||||||
assertEquals(size - index, window.size, "size of window#$index")
|
assertEquals(size - index, window.size, "size of window#$index")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -259,23 +259,36 @@ public class SequenceTest {
|
|||||||
val seq = infiniteSeq.take(7)
|
val seq = infiniteSeq.take(7)
|
||||||
|
|
||||||
val result1 = seq.windowed(4, 2)
|
val result1 = seq.windowed(4, 2)
|
||||||
|
assertEquals(listOf(
|
||||||
|
listOf(0, 1, 2, 3),
|
||||||
|
listOf(2, 3, 4, 5)
|
||||||
|
), result1.toList())
|
||||||
|
|
||||||
|
val result1partial = seq.windowed(4, 2, partialWindows = true)
|
||||||
assertEquals(listOf(
|
assertEquals(listOf(
|
||||||
listOf(0, 1, 2, 3),
|
listOf(0, 1, 2, 3),
|
||||||
listOf(2, 3, 4, 5),
|
listOf(2, 3, 4, 5),
|
||||||
listOf(4, 5, 6),
|
listOf(4, 5, 6),
|
||||||
listOf(6)
|
listOf(6)
|
||||||
), result1.toList())
|
), result1partial.toList())
|
||||||
|
|
||||||
val result2 = seq.windowed(2, 3) { it.joinToString("") }
|
val result2 = seq.windowed(2, 3) { it.joinToString("") }
|
||||||
assertEquals(listOf("01", "34", "6"), result2.toList())
|
assertEquals(listOf("01", "34"), result2.toList())
|
||||||
|
|
||||||
assertEquals(seq.chunked(2).toList(), seq.windowed(2, 2).toList())
|
val result2partial = seq.windowed(2, 3, partialWindows = true) { it.joinToString("") }
|
||||||
|
assertEquals(listOf("01", "34", "6"), result2partial.toList())
|
||||||
|
|
||||||
|
assertEquals(seq.chunked(2).toList(), seq.windowed(2, 2, partialWindows = true).toList())
|
||||||
|
|
||||||
assertEquals(seq.take(2).toList(), seq.windowed(2, size).single())
|
assertEquals(seq.take(2).toList(), seq.windowed(2, size).single())
|
||||||
assertEquals(seq.take(3).toList(), seq.windowed(3, size + 3).single())
|
assertEquals(seq.take(3).toList(), seq.windowed(3, size + 3).single())
|
||||||
|
|
||||||
val result3 = seq.windowed(size, 1)
|
|
||||||
result3.forEachIndexed { index, window ->
|
assertEquals(seq.toList(), seq.windowed(size, 1).single())
|
||||||
|
assertTrue(seq.windowed(size + 1, 1).none())
|
||||||
|
|
||||||
|
val result3partial = seq.windowed(size, 1, partialWindows = true)
|
||||||
|
result3partial.forEachIndexed { index, window ->
|
||||||
assertEquals(size - index, window.size, "size of window#$index")
|
assertEquals(size - index, window.size, "size of window#$index")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -884,18 +884,27 @@ class StringTest {
|
|||||||
val size = 7
|
val size = 7
|
||||||
val data = arg1("abcdefg")
|
val data = arg1("abcdefg")
|
||||||
val result = data.windowed(4, 2)
|
val result = data.windowed(4, 2)
|
||||||
assertEquals(listOf("abcd", "cdef", "efg", "g"), result)
|
assertEquals(listOf("abcd", "cdef"), result)
|
||||||
|
|
||||||
|
val resultPartial = data.windowed(4, 2, partialWindows = true)
|
||||||
|
assertEquals(listOf("abcd", "cdef", "efg", "g"), resultPartial)
|
||||||
|
|
||||||
val result2 = data.windowed(2, 3) { it.reversed().toString() }
|
val result2 = data.windowed(2, 3) { it.reversed().toString() }
|
||||||
assertEquals(listOf("ba", "ed", "g"), result2)
|
assertEquals(listOf("ba", "ed"), result2)
|
||||||
|
val result2partial = data.windowed(2, 3, partialWindows = true) { it.reversed().toString() }
|
||||||
|
assertEquals(listOf("ba", "ed", "g"), result2partial)
|
||||||
|
|
||||||
assertEquals(data.chunked(2), data.windowed(2, 2))
|
assertEquals(data.chunked(2), data.windowed(2, 2, partialWindows = true))
|
||||||
|
|
||||||
assertEquals(data.take(2), data.windowed(2, size).single())
|
assertEquals(data.take(2), data.windowed(2, size).single())
|
||||||
assertEquals(data.take(3), data.windowed(3, size + 3).single())
|
assertEquals(data.take(3), data.windowed(3, size + 3).single())
|
||||||
|
|
||||||
val result3 = data.windowed(size, 1)
|
|
||||||
result3.forEachIndexed { index, window ->
|
assertEquals(data.toString(), data.windowed(size, 1).single())
|
||||||
|
assertTrue(data.windowed(size + 1, 1).isEmpty())
|
||||||
|
|
||||||
|
val result3partial = data.windowed(size, 1, partialWindows = true)
|
||||||
|
result3partial.forEachIndexed { index, window ->
|
||||||
assertEquals(size - index, window.length, "size of window#$index")
|
assertEquals(size - index, window.length, "size of window#$index")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -907,8 +916,11 @@ class StringTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (window in 1..size + 1) {
|
for (window in 1..size + 1) {
|
||||||
for (step in 1..size + 1)
|
for (step in 1..size + 1) {
|
||||||
compare(data.windowed(window, step).iterator(), data.windowedSequence(window, step).iterator()) { iteratorBehavior() }
|
compare(data.windowed(window, step).iterator(), data.windowedSequence(window, step).iterator()) { iteratorBehavior() }
|
||||||
|
compare(data.windowed(window, step, partialWindows = true).iterator(),
|
||||||
|
data.windowedSequence(window, step, partialWindows = true).iterator()) { iteratorBehavior() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-8
@@ -1749,8 +1749,10 @@ public final class kotlin/collections/CollectionsKt {
|
|||||||
public static final fun toSortedSet (Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/SortedSet;
|
public static final fun toSortedSet (Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/SortedSet;
|
||||||
public static final fun union (Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
|
public static final fun union (Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
|
||||||
public static final fun unzip (Ljava/lang/Iterable;)Lkotlin/Pair;
|
public static final fun unzip (Ljava/lang/Iterable;)Lkotlin/Pair;
|
||||||
public static final fun windowed (Ljava/lang/Iterable;II)Ljava/util/List;
|
public static final fun windowed (Ljava/lang/Iterable;IIZ)Ljava/util/List;
|
||||||
public static final fun windowed (Ljava/lang/Iterable;IILkotlin/jvm/functions/Function1;)Ljava/util/List;
|
public static final fun windowed (Ljava/lang/Iterable;IIZLkotlin/jvm/functions/Function1;)Ljava/util/List;
|
||||||
|
public static synthetic fun windowed$default (Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
|
||||||
|
public static synthetic fun windowed$default (Ljava/lang/Iterable;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;
|
||||||
public static final fun withIndex (Ljava/lang/Iterable;)Ljava/lang/Iterable;
|
public static final fun withIndex (Ljava/lang/Iterable;)Ljava/lang/Iterable;
|
||||||
public static final fun withIndex (Ljava/util/Iterator;)Ljava/util/Iterator;
|
public static final fun withIndex (Ljava/util/Iterator;)Ljava/util/Iterator;
|
||||||
public static final fun zip (Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
|
public static final fun zip (Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
|
||||||
@@ -3602,8 +3604,10 @@ public final class kotlin/sequences/SequencesKt {
|
|||||||
public static final fun toSortedSet (Lkotlin/sequences/Sequence;)Ljava/util/SortedSet;
|
public static final fun toSortedSet (Lkotlin/sequences/Sequence;)Ljava/util/SortedSet;
|
||||||
public static final fun toSortedSet (Lkotlin/sequences/Sequence;Ljava/util/Comparator;)Ljava/util/SortedSet;
|
public static final fun toSortedSet (Lkotlin/sequences/Sequence;Ljava/util/Comparator;)Ljava/util/SortedSet;
|
||||||
public static final fun unzip (Lkotlin/sequences/Sequence;)Lkotlin/Pair;
|
public static final fun unzip (Lkotlin/sequences/Sequence;)Lkotlin/Pair;
|
||||||
public static final fun windowed (Lkotlin/sequences/Sequence;II)Lkotlin/sequences/Sequence;
|
public static final fun windowed (Lkotlin/sequences/Sequence;IIZ)Lkotlin/sequences/Sequence;
|
||||||
public static final fun windowed (Lkotlin/sequences/Sequence;IILkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
|
public static final fun windowed (Lkotlin/sequences/Sequence;IIZLkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
|
||||||
|
public static synthetic fun windowed$default (Lkotlin/sequences/Sequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||||
|
public static synthetic fun windowed$default (Lkotlin/sequences/Sequence;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||||
public static final fun withIndex (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
public static final fun withIndex (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
||||||
public static final fun zip (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
public static final fun zip (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
||||||
public static final fun zip (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
|
public static final fun zip (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
|
||||||
@@ -4082,10 +4086,14 @@ public final class kotlin/text/StringsKt {
|
|||||||
public static final fun trimStart (Ljava/lang/CharSequence;[C)Ljava/lang/CharSequence;
|
public static final fun trimStart (Ljava/lang/CharSequence;[C)Ljava/lang/CharSequence;
|
||||||
public static final fun trimStart (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;
|
public static final fun trimStart (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;
|
||||||
public static final fun trimStart (Ljava/lang/String;[C)Ljava/lang/String;
|
public static final fun trimStart (Ljava/lang/String;[C)Ljava/lang/String;
|
||||||
public static final fun windowed (Ljava/lang/CharSequence;II)Ljava/util/List;
|
public static final fun windowed (Ljava/lang/CharSequence;IIZ)Ljava/util/List;
|
||||||
public static final fun windowed (Ljava/lang/CharSequence;IILkotlin/jvm/functions/Function1;)Ljava/util/List;
|
public static final fun windowed (Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;)Ljava/util/List;
|
||||||
public static final fun windowedSequence (Ljava/lang/CharSequence;II)Lkotlin/sequences/Sequence;
|
public static synthetic fun windowed$default (Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;
|
||||||
public static final fun windowedSequence (Ljava/lang/CharSequence;IILkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
|
public static synthetic fun windowed$default (Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;
|
||||||
|
public static final fun windowedSequence (Ljava/lang/CharSequence;IIZ)Lkotlin/sequences/Sequence;
|
||||||
|
public static final fun windowedSequence (Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
|
||||||
|
public static synthetic fun windowedSequence$default (Ljava/lang/CharSequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||||
|
public static synthetic fun windowedSequence$default (Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||||
public static final fun withIndex (Ljava/lang/CharSequence;)Ljava/lang/Iterable;
|
public static final fun withIndex (Ljava/lang/CharSequence;)Ljava/lang/Iterable;
|
||||||
public static final fun zip (Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/util/List;
|
public static final fun zip (Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/util/List;
|
||||||
public static final fun zip (Ljava/lang/CharSequence;Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function2;)Ljava/util/List;
|
public static final fun zip (Ljava/lang/CharSequence;Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function2;)Ljava/util/List;
|
||||||
|
|||||||
+16
-8
@@ -1608,8 +1608,10 @@ public final class kotlin/collections/CollectionsKt {
|
|||||||
public static final fun toSortedSet (Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/SortedSet;
|
public static final fun toSortedSet (Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/SortedSet;
|
||||||
public static final fun union (Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
|
public static final fun union (Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
|
||||||
public static final fun unzip (Ljava/lang/Iterable;)Lkotlin/Pair;
|
public static final fun unzip (Ljava/lang/Iterable;)Lkotlin/Pair;
|
||||||
public static final fun windowed (Ljava/lang/Iterable;II)Ljava/util/List;
|
public static final fun windowed (Ljava/lang/Iterable;IIZ)Ljava/util/List;
|
||||||
public static final fun windowed (Ljava/lang/Iterable;IILkotlin/jvm/functions/Function1;)Ljava/util/List;
|
public static final fun windowed (Ljava/lang/Iterable;IIZLkotlin/jvm/functions/Function1;)Ljava/util/List;
|
||||||
|
public static synthetic fun windowed$default (Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
|
||||||
|
public static synthetic fun windowed$default (Ljava/lang/Iterable;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;
|
||||||
public static final fun withIndex (Ljava/lang/Iterable;)Ljava/lang/Iterable;
|
public static final fun withIndex (Ljava/lang/Iterable;)Ljava/lang/Iterable;
|
||||||
public static final fun withIndex (Ljava/util/Iterator;)Ljava/util/Iterator;
|
public static final fun withIndex (Ljava/util/Iterator;)Ljava/util/Iterator;
|
||||||
public static final fun zip (Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
|
public static final fun zip (Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
|
||||||
@@ -2297,8 +2299,10 @@ public final class kotlin/sequences/SequencesKt {
|
|||||||
public static final fun toSortedSet (Lkotlin/sequences/Sequence;)Ljava/util/SortedSet;
|
public static final fun toSortedSet (Lkotlin/sequences/Sequence;)Ljava/util/SortedSet;
|
||||||
public static final fun toSortedSet (Lkotlin/sequences/Sequence;Ljava/util/Comparator;)Ljava/util/SortedSet;
|
public static final fun toSortedSet (Lkotlin/sequences/Sequence;Ljava/util/Comparator;)Ljava/util/SortedSet;
|
||||||
public static final fun unzip (Lkotlin/sequences/Sequence;)Lkotlin/Pair;
|
public static final fun unzip (Lkotlin/sequences/Sequence;)Lkotlin/Pair;
|
||||||
public static final fun windowed (Lkotlin/sequences/Sequence;II)Lkotlin/sequences/Sequence;
|
public static final fun windowed (Lkotlin/sequences/Sequence;IIZ)Lkotlin/sequences/Sequence;
|
||||||
public static final fun windowed (Lkotlin/sequences/Sequence;IILkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
|
public static final fun windowed (Lkotlin/sequences/Sequence;IIZLkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
|
||||||
|
public static synthetic fun windowed$default (Lkotlin/sequences/Sequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||||
|
public static synthetic fun windowed$default (Lkotlin/sequences/Sequence;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||||
public static final fun withIndex (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
public static final fun withIndex (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
||||||
public static final fun zip (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
public static final fun zip (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
||||||
public static final fun zip (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
|
public static final fun zip (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
|
||||||
@@ -2777,10 +2781,14 @@ public final class kotlin/text/StringsKt {
|
|||||||
public static final fun trimStart (Ljava/lang/CharSequence;[C)Ljava/lang/CharSequence;
|
public static final fun trimStart (Ljava/lang/CharSequence;[C)Ljava/lang/CharSequence;
|
||||||
public static final fun trimStart (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;
|
public static final fun trimStart (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;
|
||||||
public static final fun trimStart (Ljava/lang/String;[C)Ljava/lang/String;
|
public static final fun trimStart (Ljava/lang/String;[C)Ljava/lang/String;
|
||||||
public static final fun windowed (Ljava/lang/CharSequence;II)Ljava/util/List;
|
public static final fun windowed (Ljava/lang/CharSequence;IIZ)Ljava/util/List;
|
||||||
public static final fun windowed (Ljava/lang/CharSequence;IILkotlin/jvm/functions/Function1;)Ljava/util/List;
|
public static final fun windowed (Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;)Ljava/util/List;
|
||||||
public static final fun windowedSequence (Ljava/lang/CharSequence;II)Lkotlin/sequences/Sequence;
|
public static synthetic fun windowed$default (Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;
|
||||||
public static final fun windowedSequence (Ljava/lang/CharSequence;IILkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
|
public static synthetic fun windowed$default (Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;
|
||||||
|
public static final fun windowedSequence (Ljava/lang/CharSequence;IIZ)Lkotlin/sequences/Sequence;
|
||||||
|
public static final fun windowedSequence (Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
|
||||||
|
public static synthetic fun windowedSequence$default (Ljava/lang/CharSequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||||
|
public static synthetic fun windowedSequence$default (Ljava/lang/CharSequence;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||||
public static final fun withIndex (Ljava/lang/CharSequence;)Ljava/lang/Iterable;
|
public static final fun withIndex (Ljava/lang/CharSequence;)Ljava/lang/Iterable;
|
||||||
public static final fun zip (Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/util/List;
|
public static final fun zip (Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/util/List;
|
||||||
public static final fun zip (Ljava/lang/CharSequence;Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function2;)Ljava/util/List;
|
public static final fun zip (Ljava/lang/CharSequence;Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function2;)Ljava/util/List;
|
||||||
|
|||||||
@@ -559,7 +559,7 @@ fun generators(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("windowed(size: Int, step: Int, transform: (List<T>) -> R)") {
|
templates add f("windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R)") {
|
||||||
since("1.2")
|
since("1.2")
|
||||||
only(Iterables, Sequences, CharSequences)
|
only(Iterables, Sequences, CharSequences)
|
||||||
doc { f ->
|
doc { f ->
|
||||||
@@ -574,7 +574,9 @@ fun generators(): List<GenericFunction> {
|
|||||||
|
|
||||||
Both [size] and [step] must be positive and can be greater than the number of elements in this ${f.collection}.
|
Both [size] and [step] must be positive and can be greater than the number of elements in this ${f.collection}.
|
||||||
@param size the number of elements to take in each window
|
@param size the number of elements to take in each window
|
||||||
@param step the number of elements to move the window forward by on an each step
|
@param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
@param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
by default `false` which means partial windows won't be preserved
|
||||||
|
|
||||||
@sample samples.collections.Sequences.Transformations.averageWindows
|
@sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
"""
|
"""
|
||||||
@@ -593,20 +595,21 @@ fun generators(): List<GenericFunction> {
|
|||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
window.move(index, (index + size).coerceAtMost(thisSize))
|
window.move(index, (index + size).coerceAtMost(thisSize))
|
||||||
|
if (!partialWindows && window.size < size) break
|
||||||
result.add(transform(window))
|
result.add(transform(window))
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
val result = ArrayList<R>()
|
val result = ArrayList<R>()
|
||||||
windowedIterator(iterator(), size, step, dropTrailing = false, reuseBuffer = true).forEach {
|
windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = true).forEach {
|
||||||
result.add(transform(it))
|
result.add(transform(it))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
customSignature(CharSequences) { "windowed(size: Int, step: Int, transform: (CharSequence) -> R)" }
|
customSignature(CharSequences) { "windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R)" }
|
||||||
body(CharSequences) {
|
body(CharSequences) {
|
||||||
"""
|
"""
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
@@ -614,7 +617,9 @@ fun generators(): List<GenericFunction> {
|
|||||||
val result = ArrayList<R>((thisSize + step - 1) / step)
|
val result = ArrayList<R>((thisSize + step - 1) / step)
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
result.add(transform(subSequence(index, (index + size).coerceAtMost(thisSize))))
|
val end = index + size
|
||||||
|
val coercedEnd = if (end > thisSize) { if (partialWindows) thisSize else break } else end
|
||||||
|
result.add(transform(subSequence(index, coercedEnd)))
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -624,12 +629,12 @@ fun generators(): List<GenericFunction> {
|
|||||||
returns(Sequences) { "Sequence<R>" }
|
returns(Sequences) { "Sequence<R>" }
|
||||||
body(Sequences) {
|
body(Sequences) {
|
||||||
"""
|
"""
|
||||||
return windowedSequence(size, step, dropTrailing = false, reuseBuffer = true).map(transform)
|
return windowedSequence(size, step, partialWindows, reuseBuffer = true).map(transform)
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("windowed(size: Int, step: Int)") {
|
templates add f("windowed(size: Int, step: Int = 1, partialWindows: Boolean = false)") {
|
||||||
since("1.2")
|
since("1.2")
|
||||||
only(Iterables, Sequences, CharSequences)
|
only(Iterables, Sequences, CharSequences)
|
||||||
returns(Iterables) { "List<List<T>>" }
|
returns(Iterables) { "List<List<T>>" }
|
||||||
@@ -646,7 +651,9 @@ fun generators(): List<GenericFunction> {
|
|||||||
|
|
||||||
Both [size] and [step] must be positive and can be greater than the number of elements in this ${f.collection}.
|
Both [size] and [step] must be positive and can be greater than the number of elements in this ${f.collection}.
|
||||||
@param size the number of elements to take in each window
|
@param size the number of elements to take in each window
|
||||||
@param step the number of elements to move the window forward by on an each step
|
@param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
@param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
by default `false` which means partial windows won't be preserved
|
||||||
|
|
||||||
@sample samples.collections.Sequences.Transformations.takeWindows
|
@sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
"""
|
"""
|
||||||
@@ -660,27 +667,29 @@ fun generators(): List<GenericFunction> {
|
|||||||
val result = ArrayList<List<T>>((thisSize + step - 1) / step)
|
val result = ArrayList<List<T>>((thisSize + step - 1) / step)
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < thisSize) {
|
while (index < thisSize) {
|
||||||
result.add(List(size.coerceAtMost(thisSize - index)) { this[it + index] })
|
val windowSize = size.coerceAtMost(thisSize - index)
|
||||||
|
if (windowSize < size && !partialWindows) break
|
||||||
|
result.add(List(windowSize) { this[it + index] })
|
||||||
index += step
|
index += step
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
val result = ArrayList<List<T>>()
|
val result = ArrayList<List<T>>()
|
||||||
windowedIterator(iterator(), size, step, dropTrailing = false, reuseBuffer = false).forEach {
|
windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = false).forEach {
|
||||||
result.add(it)
|
result.add(it)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences) { "return windowed(size, step) { it.toString() }" }
|
body(CharSequences) { "return windowed(size, step, partialWindows) { it.toString() }" }
|
||||||
body(Sequences) {
|
body(Sequences) {
|
||||||
"""
|
"""
|
||||||
return windowedSequence(size, step, dropTrailing = false, reuseBuffer = false)
|
return windowedSequence(size, step, partialWindows, reuseBuffer = false)
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("windowedSequence(size: Int, step: Int, transform: (CharSequence) -> R)") {
|
templates add f("windowedSequence(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R)") {
|
||||||
since("1.2")
|
since("1.2")
|
||||||
only(CharSequences)
|
only(CharSequences)
|
||||||
doc { f ->
|
doc { f ->
|
||||||
@@ -695,7 +704,9 @@ fun generators(): List<GenericFunction> {
|
|||||||
|
|
||||||
Both [size] and [step] must be positive and can be greater than the number of elements in this ${f.collection}.
|
Both [size] and [step] must be positive and can be greater than the number of elements in this ${f.collection}.
|
||||||
@param size the number of elements to take in each window
|
@param size the number of elements to take in each window
|
||||||
@param step the number of elements to move the window forward by on an each step
|
@param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
@param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
by default `false` which means partial windows won't be preserved
|
||||||
|
|
||||||
@sample samples.collections.Sequences.Transformations.averageWindows
|
@sample samples.collections.Sequences.Transformations.averageWindows
|
||||||
"""
|
"""
|
||||||
@@ -706,12 +717,13 @@ fun generators(): List<GenericFunction> {
|
|||||||
body {
|
body {
|
||||||
"""
|
"""
|
||||||
checkWindowSizeStep(size, step)
|
checkWindowSizeStep(size, step)
|
||||||
return (indices step step).asSequence().map { index -> transform(subSequence(index, (index + size).coerceAtMost(length))) }
|
val windows = (if (partialWindows) indices else 0 until length - size + 1) step step
|
||||||
|
return windows.asSequence().map { index -> transform(subSequence(index, (index + size).coerceAtMost(length))) }
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("windowedSequence(size: Int, step: Int)") {
|
templates add f("windowedSequence(size: Int, step: Int = 1, partialWindows: Boolean = false)") {
|
||||||
since("1.2")
|
since("1.2")
|
||||||
only(CharSequences)
|
only(CharSequences)
|
||||||
doc { f ->
|
doc { f ->
|
||||||
@@ -724,14 +736,16 @@ fun generators(): List<GenericFunction> {
|
|||||||
|
|
||||||
Both [size] and [step] must be positive and can be greater than the number of elements in this ${f.collection}.
|
Both [size] and [step] must be positive and can be greater than the number of elements in this ${f.collection}.
|
||||||
@param size the number of elements to take in each window
|
@param size the number of elements to take in each window
|
||||||
@param step the number of elements to move the window forward by on an each step
|
@param step the number of elements to move the window forward by on an each step, by default 1
|
||||||
|
@param partialWindows controls whether or not to keep partial windows in the end if any,
|
||||||
|
by default `false` which means partial windows won't be preserved
|
||||||
|
|
||||||
@sample samples.collections.Sequences.Transformations.takeWindows
|
@sample samples.collections.Sequences.Transformations.takeWindows
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
returns { "Sequence<String> "}
|
returns { "Sequence<String> "}
|
||||||
|
|
||||||
body(CharSequences) { "return windowedSequence(size, step) { it.toString() }" }
|
body(CharSequences) { "return windowedSequence(size, step, partialWindows) { it.toString() }" }
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("chunked(size: Int, transform: (List<T>) -> R)") {
|
templates add f("chunked(size: Int, transform: (List<T>) -> R)") {
|
||||||
@@ -761,7 +775,7 @@ fun generators(): List<GenericFunction> {
|
|||||||
|
|
||||||
sequenceClassification(intermediate, stateful)
|
sequenceClassification(intermediate, stateful)
|
||||||
returns(Sequences) { "Sequence<R>" }
|
returns(Sequences) { "Sequence<R>" }
|
||||||
body { "return windowed(size, size, transform)" }
|
body { "return windowed(size, size, partialWindows = true, transform = transform)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("chunked(size: Int)") {
|
templates add f("chunked(size: Int)") {
|
||||||
@@ -784,7 +798,7 @@ fun generators(): List<GenericFunction> {
|
|||||||
|
|
||||||
sequenceClassification(intermediate, stateful)
|
sequenceClassification(intermediate, stateful)
|
||||||
|
|
||||||
body { "return windowed(size, size)" }
|
body { "return windowed(size, size, partialWindows = true)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("chunkedSequence(size: Int, transform: (CharSequence) -> R)") {
|
templates add f("chunkedSequence(size: Int, transform: (CharSequence) -> R)") {
|
||||||
@@ -812,7 +826,7 @@ fun generators(): List<GenericFunction> {
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
"""
|
"""
|
||||||
return windowedSequence(size, size, transform)
|
return windowedSequence(size, size, partialWindows = true, transform = transform)
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user