赞
踩
fun <T> splitGroup(list:List<T>, groupSize:Int, subListCallback:((List<T>) -> Unit) ?= null) {
val groupNum = list.size / groupSize
val remainLast = list.size % groupSize
for (index in 0 until groupNum) {
val start = index * groupSize
subListCallback?.invoke(list.subList(start, start + groupSize))
}
if (remainLast > 0) {
val index = (groupNum) * groupSize
subListCallback?.invoke(list.subList(index, index + remainLast))
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。