filter(Predicate) vs. takeWhile(Predicate) or dropWhile(Predicate) #51
Answered
by
coalong
corock
asked this question in
CHAPTER 5 스트림 활용 - Q&A
-
|
Beta Was this translation helpful? Give feedback.
Answered by
coalong
Jul 3, 2023
Replies: 1 comment 2 replies
-
|
제 생각은 정렬되어 있는 요소를 탐색할 때는 만약 정렬되어 있지 않은 요소를 탐색할 때는 |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Irisation23
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
제 생각은 정렬되어 있는 요소를 탐색할 때는
성능상
filter를 사용하는 것보다takeWhile,dropWhile을 사용하는 것이 좋다고 생각합니다.만약 정렬되어 있지 않은 요소를 탐색할 때는
takeWhile이나dropWhile로 원하는 결과를 못 얻을 수 있다고 생각되는데,이런 상황에서는 1)
sorted와takeWhileordropWhile를 같이 사용하는 경우,2)
filter을 사용하는 경우 어떤 것이 더 좋을지 궁금합니다.