Open
Conversation
hannut91
approved these changes
Jan 2, 2024
Comment on lines
+51
to
+54
| if (this.get(key)) { | ||
| return true; | ||
| } | ||
| return false; |
Contributor
There was a problem hiding this comment.
JavaScript에서 이런 경우 이렇게도 많이 씁니다.
return !!this.get(key);변수 앞에 !를 붙이면 true -> false, false -> true로 바뀌잖아요. 이걸 2번 하면 true -> false -> true가 되겠죠. 어차피 아무것도 안하는데 왜 쓰냐고 할 수 있지만, 자바스크립트에는 Truthy와 Falsy가 있어요. 1, {}, [], 길이 1이상 문자열 등등은 true라고 가정하고, undefined, null, 0, "" 빈 문자열 등은 false라고 가정하죠.
그래서 어떤 객체가 주어졌을 때 !를 하나 붙이면 false가 되고 여기서 !를 하나 더 붙이면 true가 되므로 어떤 값이 있다는 것을 boolean변수로 변환할 수 있죠.
See also
Comment on lines
+58
to
+60
| if (this.#n === 0) { | ||
| return true; | ||
| } return false; |
Contributor
There was a problem hiding this comment.
return this.#n === 0;이렇게 써도 되겠네요
| } | ||
|
|
||
| keys() { | ||
| return this.#keys; |
Contributor
There was a problem hiding this comment.
각 속성들을 private으로 선언한 이유가 외부에서 함 부로 접근하고 수정하지 못하도록 한거예요. 여기서 this.#keys를 직접 반환하게 되면 외부에서 값을 조작할 수 있어서 위험할 수 있어요. 이럴 때는 복사해서 넘겨주는게 좋습니다. 그러면 복사한 값을 고쳐도 안에 있는 값에는 영향을 받지 않아요.
return [...this.#keys];
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
마지막 선형 탐지 해싱 테이블은 그림은 그렸는데 구현은 못했습니다ㅜ
이진탐색트리

2-3트리

레드블랙트리

개별해시테이블, 선형해시테이블
