I have a list like : lst = {"a","b","c","b","c","a","c","a","b"}
I want to divide this in chunks :
like first chunk : a,b,c second is : b,c,a third is : c,a,b
Please note these chunks can be in any order and are not the simple String object, but can be anything (Viz: Complex object, Map etc).
Also I cannot break into chunks blindly since data in each chunk should be same and its a related data ie: in first chunk a,b,c are interrelated..likewise in second chunk b,c,a are interrelated and so on.
How can I do that.
One possible way I was thinking was to use collectors and groups by in Java8.
Any suggestions.
PS: Please ignore the syntax, this is just for understanding purpose.
Note: The answer for which it is marked duplicate here does not apply.
> listStripes = IntStream.range(0, (lst.length+stripe-1)/stripe).mapToObj(i -> realList.subList(i*stripe, Math.min(lst.length, (i+1)*stripe))).collect(Collectors.toList());` Drawbacks: inner `List` are just views onto the initial `List`, so modifying the latter **will** change the former. Beware!
Advantages: creating such fragments don't require copying arrays. Faster!