Class CustomCollectors
java.lang.Object
com.ggalmazor.ltdownsampling.tools.CustomCollectors
Utility class to wire in the sliding window collector defined by
SlidingCollector-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsliding(int size) Collects aStreaminto lists of consecutive elements in groups of the providedsizewithout overlaps or gapssliding(int size, int step) Collects aStreaminto lists of consecutive elements in groups of the providedsize, advancing the providedstepelements between each group.
-
Constructor Details
-
CustomCollectors
public CustomCollectors()
-
-
Method Details
-
sliding
Collects aStreaminto lists of consecutive elements in groups of the providedsizewithout overlaps or gaps- Type Parameters:
T- the type of elements in theStreambeing collected- Parameters:
size- the size of the output lists- Returns:
- a list of lists
-
sliding
Collects aStreaminto lists of consecutive elements in groups of the providedsize, advancing the providedstepelements 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 theStreambeing 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
-