内存分页

public static <T> PageResult<T> newPage(List<T> content, Integer pageNum, Integer pages) {

int total = content.size();
int offset = (pageNum -1 ) * pages;

if (offset > total) {
return new PageResult<T>(null, pageNum, pages, (long)total);
}
final List<T> paged = content.subList(offset, Math.min(total, offset + pages));

return new PageResult<T>(paged, pageNum, pages, (long)total);
}
posted @ 2023-04-27 13:57  Acaak  阅读(32)  评论(0)    收藏  举报