java
java list slice 성능 비교
즐겁게살자
2022. 5. 11. 11:26
728x90
oom 우려로 리스트를 특정 사이즈 만큼 slice 해서 처리 하는 로직을 구현하는 일이 생겼다.
stream을 이용해서 좀더 모던한(?) 느낌을 주고 싶어 검색해 봤는데, List.subList 가 제일 성능이 좋다는 블러그를 발견해서
기록해둔다.
https://e.printstacktrace.blog/divide-a-list-to-lists-of-n-size-in-Java-8/
Divide a list to lists of n size in Java 8
Every Java developer works with lists daily. There are many popular list (or collection) operations implemented in the standard Java 8 library, but there is one that is useful and commonly used, yet
e.printstacktrace.blog
** 추가로 list를 slice 하는 여러가지 라이브러리를 소개해준 글도 있다.
역시 찾아보면 다 제공해주는 유틸이 있어서 굳이 구현 안해도 되네...