Class CustomCollectors
java.lang.Object
com.ggalmazor.ltdownsampling.tools.CustomCollectors
Utility class to wire in the sliding window collector defined by
SlidingCollector
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionsliding
(int size) Collects aStream
into lists of consecutive elements in groups of the providedsize
without overlaps or gapssliding
(int size, int step) Collects aStream
into lists of consecutive elements in groups of the providedsize
, advancing the providedstep
elements between each group.
-
Constructor Details
-
CustomCollectors
public CustomCollectors()
-
-
Method Details
-
sliding
Collects aStream
into lists of consecutive elements in groups of the providedsize
without overlaps or gaps- Type Parameters:
T
- the type of elements in theStream
being collected- Parameters:
size
- the size of the output lists- Returns:
- a list of lists
-
sliding
Collects aStream
into lists of consecutive elements in groups of the providedsize
, advancing the providedstep
elements between each group.Depending on the value of
step
, the resulting lists can have overlaps, or gaps:sliding(2,1)
will produce overlapping lists (every input element is present in two output elements except for the first and the last input elements)sliding(2,3)
will produce a list with gaps (every third input element is skipped)
- Type Parameters:
T
- the type of elements in theStream
being collected- Parameters:
size
- the number of elements on each list element in the output liststep
- the number of input elements to skip after each list element in the output list- Returns:
- a list of lists
-