Coverage Summary for Class: PrefetchKt (com.vsevolodganin.clicktrack.utils.collection.sequence)
Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
PrefetchKt |
0%
(0/1)
|
0%
(0/4)
|
0%
(0/8)
|
0%
(0/38)
|
PrefetchKt$prefetch$2 |
0%
(0/1)
|
|
0%
(0/2)
|
0%
(0/33)
|
Total |
0%
(0/2)
|
0%
(0/4)
|
0%
(0/10)
|
0%
(0/71)
|
package com.vsevolodganin.clicktrack.utils.collection.sequence
fun <T> Sequence<T>.prefetch(n: Int): Sequence<T> {
val prefetched = ArrayList<T>(n)
val iterator = iterator()
repeat(n) {
if (iterator.hasNext()) {
prefetched += iterator.next()
}
}
return sequence {
yieldAll(prefetched)
yieldAll(iterator)
}.constrainOnce()
}