Docs and samples for 'windowed' function
This commit is contained in:
@@ -562,8 +562,25 @@ fun generators(): List<GenericFunction> {
|
||||
templates add f("windowed(size: Int, step: Int, transform: (List<T>) -> R)") {
|
||||
since("1.2")
|
||||
only(Iterables, Sequences, CharSequences)
|
||||
typeParam("R")
|
||||
doc { f ->
|
||||
"""
|
||||
Returns a ${f.mapResult} of results of applying the given [transform] function to
|
||||
an each ${f.viewResult} representing a view over the window of the given [size]
|
||||
sliding along this ${f.collection} with the given [step].
|
||||
|
||||
Note that the ${f.viewResult} passed to the [transform] function is ephemeral and is valid only inside that function.
|
||||
You should not store it or allow it to escape in some way, unless you made a snapshot of it.
|
||||
Several last ${f.viewResult.pluralize()} may have less ${f.element.pluralize()} than the given [size].
|
||||
|
||||
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 step the number of elements to move the window forward by on an each step
|
||||
|
||||
@sample samples.collections.Sequences.Transformations.averageWindows
|
||||
"""
|
||||
}
|
||||
|
||||
typeParam("R")
|
||||
returns("List<R>")
|
||||
|
||||
body {
|
||||
@@ -619,6 +636,21 @@ fun generators(): List<GenericFunction> {
|
||||
returns(Sequences) { "Sequence<List<T>>" }
|
||||
returns(CharSequences) { "List<String>" }
|
||||
|
||||
doc { f ->
|
||||
"""
|
||||
Returns a ${f.mapResult} of snapshots of the window of the given [size]
|
||||
sliding along this ${f.collection} with the given [step], where each
|
||||
snapshot is ${f.snapshotResult.prefixWithArticle()}.
|
||||
|
||||
Several last ${f.snapshotResult.pluralize()} may have less ${f.element.pluralize()} than the given [size].
|
||||
|
||||
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 step the number of elements to move the window forward by on an each step
|
||||
|
||||
@sample samples.collections.Sequences.Transformations.takeWindows
|
||||
"""
|
||||
}
|
||||
|
||||
body {
|
||||
"""
|
||||
@@ -651,6 +683,23 @@ fun generators(): List<GenericFunction> {
|
||||
templates add f("windowedSequence(size: Int, step: Int, transform: (CharSequence) -> R)") {
|
||||
since("1.2")
|
||||
only(CharSequences)
|
||||
doc { f ->
|
||||
"""
|
||||
Returns a sequence of results of applying the given [transform] function to
|
||||
an each ${f.viewResult} representing a view over the window of the given [size]
|
||||
sliding along this ${f.collection} with the given [step].
|
||||
|
||||
Note that the ${f.viewResult} passed to the [transform] function is ephemeral and is valid only inside that function.
|
||||
You should not store it or allow it to escape in some way, unless you made a snapshot of it.
|
||||
Several last ${f.viewResult.pluralize()} may have less ${f.element.pluralize()} than the given [size].
|
||||
|
||||
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 step the number of elements to move the window forward by on an each step
|
||||
|
||||
@sample samples.collections.Sequences.Transformations.averageWindows
|
||||
"""
|
||||
}
|
||||
typeParam("R")
|
||||
returns { "Sequence<R> "}
|
||||
|
||||
@@ -665,6 +714,21 @@ fun generators(): List<GenericFunction> {
|
||||
templates add f("windowedSequence(size: Int, step: Int)") {
|
||||
since("1.2")
|
||||
only(CharSequences)
|
||||
doc { f ->
|
||||
"""
|
||||
Returns a sequence of snapshots of the window of the given [size]
|
||||
sliding along this ${f.collection} with the given [step], where each
|
||||
snapshot is ${f.snapshotResult.prefixWithArticle()}.
|
||||
|
||||
Several last ${f.snapshotResult.pluralize()} may have less ${f.element.pluralize()} than the given [size].
|
||||
|
||||
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 step the number of elements to move the window forward by on an each step
|
||||
|
||||
@sample samples.collections.Sequences.Transformations.takeWindows
|
||||
"""
|
||||
}
|
||||
returns { "Sequence<String> "}
|
||||
|
||||
body(CharSequences) { "return windowedSequence(size, step) { it.toString() }" }
|
||||
@@ -681,7 +745,7 @@ fun generators(): List<GenericFunction> {
|
||||
@return ${f.mapResult} of results of the [transform] applied to an each ${f.viewResult}.
|
||||
|
||||
Note that the ${f.viewResult} passed to the [transform] function is ephemeral and is valid only inside that function.
|
||||
You should not store it or allow it escape someway, unless you made a snapshot of it.
|
||||
You should not store it or allow it to escape in some way, unless you made a snapshot of it.
|
||||
The last ${f.viewResult} may have less ${f.element.pluralize()} than the given [size].
|
||||
|
||||
@param size the number of elements to take in each ${f.viewResult}, must be positive and can be greater than the number of elements in this ${f.collection}.
|
||||
@@ -734,7 +798,7 @@ fun generators(): List<GenericFunction> {
|
||||
@return sequence of results of the [transform] applied to an each ${f.viewResult}.
|
||||
|
||||
Note that the ${f.viewResult} passed to the [transform] function is ephemeral and is valid only inside that function.
|
||||
You should not store it or allow it to escape someway, unless you made a snapshot of it.
|
||||
You should not store it or allow it to escape in some way, unless you made a snapshot of it.
|
||||
The last ${f.viewResult} may have less ${f.element.pluralize()} than the given [size].
|
||||
|
||||
@param size the number of elements to take in each ${f.viewResult}, must be positive and can be greater than the number of elements in this ${f.collection}.
|
||||
|
||||
Reference in New Issue
Block a user