com.bericotech.clavin.util
Class ListUtils

java.lang.Object
  extended by com.bericotech.clavin.util.ListUtils

public class ListUtils
extends Object

Utility methods for list processing.


Constructor Summary
ListUtils()
           
 
Method Summary
static
<T> List<List<T>>
chunkifyList(List<T> list, int maxChunkSize)
          Splits a list into a set of sublists (preserving order) where the size of each sublist is bound by a given max size, and ensuring that no list has fewer than half the max size number of elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListUtils

public ListUtils()
Method Detail

chunkifyList

public static <T> List<List<T>> chunkifyList(List<T> list,
                                             int maxChunkSize)
Splits a list into a set of sublists (preserving order) where the size of each sublist is bound by a given max size, and ensuring that no list has fewer than half the max size number of elements. In other words, you won't get a little rinky-dink sublist at the end that only has one or two items from the original list. Based on: http://www.chinhdo.com/20080515/chunking/

Parameters:
list - list to be chunkified
maxChunkSize - how big you want the chunks to be
Returns:
a chunkified list (i.e., list of sublists)


Copyright © 2013 Berico Technologies. All rights reserved.