ArrayList/JAEKWANG97#6
Open
JAEKWANG97 wants to merge 1 commit into
Open
Conversation
hellomatia
reviewed
May 20, 2024
Comment on lines
+34
to
+42
| @Override | ||
| public void insert(Object data) { | ||
| elementData[size] = data; | ||
| size++; | ||
|
|
||
| if (size == elementData.length) { | ||
| grow(); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
저는 추가 시 size를 확인 용량을 늘려주었습니다. size가 용량을 넘으면, 2배로 바로 늘려주게 되면 추가로 element를 넣지 않으면 메모리 낭비가 생기지 않을까요? @JAEKWANG97 님의 의견이 궁금해요!
Member
Author
There was a problem hiding this comment.
@hellomatia 님 좋은 지적 감사드립니다. 말씀해주신 대로, size가 용량을 초과하는 경우 배열 크기를 2배로 늘리는 로직은 실제로 메모리 낭비를 일으킬 수 있습니다. 이 부분에 대해 충분히 고려하지 못했던 것 같습니다. 귀중한 피드백을 통해 많이 배우게 되었습니다. 감사합니다!
Open
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.
ArrayList
📝 구현하면서 어려웠던 점
💬 리뷰 요구사항(선택)