Skip to content

filter(Predicate) vs. takeWhile(Predicate) or dropWhile(Predicate) #51

Discussion options

You must be logged in to vote

제 생각은 정렬되어 있는 요소를 탐색할 때는
성능상 filter 를 사용하는 것보다 takeWhile, dropWhile 을 사용하는 것이 좋다고 생각합니다.

만약 정렬되어 있지 않은 요소를 탐색할 때는 takeWhile 이나 dropWhile 로 원하는 결과를 못 얻을 수 있다고 생각되는데,
이런 상황에서는 1) sortedtakeWhile or dropWhile 를 같이 사용하는 경우,
2)filter 을 사용하는 경우 어떤 것이 더 좋을지 궁금합니다.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@BvrPark
Comment options

@JoisFe
Comment options

Answer selected by Irisation23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CoRock 제훈님을 위한 라벨입니다. Q&A Q&A를 위한 라벨입니다. Chapter 5 Chapter 5 정리를 위한 라벨입니다.
4 participants