[ 
https://issues.apache.org/jira/browse/COLLECTIONS-800?focusedWorklogId=676747&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-676747
 ]

ASF GitHub Bot logged work on COLLECTIONS-800:
----------------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Nov/21 21:30
            Start Date: 04/Nov/21 21:30
    Worklog Time Spent: 10m 
      Work Description: ClaudioConsolmagno opened a new pull request #265:
URL: https://github.com/apache/commons-collections/pull/265


   See 
[COLLECTIONS-800](https://issues.apache.org/jira/projects/COLLECTIONS/issues/COLLECTIONS-800)
   
   Implementation Notes:
   - Given that the `Partition` class is a private static class not used by 
anything else I think it's ok to just use isBalanced as a boolean instead of, 
say, an enum or having a separate brand new private class for this new method.
   - Added several comments to clarify the logic, let me know if you think 
that's too much.
   - I didn't know how far I could go when refactoring existing tests so I only 
half changed them for `partition()` method. 
   - Similarly, existing tests all around seem fairly simple but I thought I 
should have good coverage and test different scenarios for partitionBalanced() 
hence added the whole `forEach` test cases (I'm a fan of Spock and data driven 
testing).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 676747)
    Remaining Estimate: 0h
            Time Spent: 10m

> 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
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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)

Reply via email to