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 gaps.sliding(int size, int step) Collects aStreaminto lists of consecutive elements in groups of the providedsize, advancingstepelements 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, advancingstepelements between each group.Depending on the value of
step, the resulting lists can have overlaps or gaps:sliding(2,1)produces overlapping lists (every input element is present in two output elements except for the first and last).sliding(2,3)produces 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 in each list element of the output liststep- the number of input elements to advance after each output list element- Returns:
- a list of lists
-