Claudio created COLLECTIONS-800:
-----------------------------------
Summary: Provide a ListUtils.partitionBalanced(List, int) method
where returned sublists are "balanced"
Key: COLLECTIONS-800
URL: https://issues.apache.org/jira/browse/COLLECTIONS-800
Project: Commons Collections
Issue Type: New Feature
Components: List
Reporter: Claudio
The new method re-uses some of the logic of the existing
ListUtils.partition(List, int). The difference with that method is that the
returned sublists are "balanced" so that they all have the same amount of
elements (with a maximum of 1 element difference). Some examples:
A list of 10 elements, partition 10:
* partition() and partitionBalanced() both return a single sublist with 10
elements
A list of 11 elements, partition 10:
* partition() returns a sublist of 10 and another sublist of 1 element
* partitionBalanced() method returns a sublist of 6 and another sublist of 5
elements
A list of 14 elements, partition 10:
* partition() returns a sublist of 10 and another sublist of 4 elements
* partitionBalanced() method returns two sublists of 7 elements each
A list of 20 elements, partition 10:
* partition() and partitionBalanced() both return two sublists of 10 elements
If we are ok to add this feature, I have a working implementation with tests
and I'm happy to create a PR on Github.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)