dropEveryNth()
Drop every
n
th element of the stream.Implementation Notes
This is syntactic sugar on top of filterIndexed()
. For a version
of this gatherer that keeps every nth element instead of dropping them, see the takeEveryNth()
Gatherer.
Signature
dropEveryNth(int count)
count
- The periodic number of the elements to keep, must be at least 2
Examples
Drop every 3rd element
Stream
.of("A", "B", "C", "D", "E", "F", "G")
.gather(Gatherers4j.dropEveryNth(3))
.toList();
// ["B", "C", "E", "F"]