How does .count() operation work on Sequences? Does it aggregate all elements going through the sequence and then counts them all at the end very much like .size() in Collections or is it just a counter that increments with each element? I have a potentially infinite/very long sequence and started wondering if this could lead to memory issues at some point down the line.
k
kristofdho
06/20/2018, 11:45 AM
it is open source you know..
Copy code
public fun <T> Sequence<T>.count(): Int {
var count = 0
for (element in this) count++
return count
}