Skip to content

Update List.java #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2017
Merged

Update List.java #22

merged 1 commit into from
Jan 27, 2017

Conversation

samyanez94
Copy link
Contributor

In the add method for ArrayList, when the index of the element that is inserted is smaller than the size of the list, the algorithm shift the array down one spot and inserts the value at the desired position. However, it does not increases the size of the list after that, which may cause some problems when iterating through the ArrayList.

Hi Justin, I'm a big fan of your code, but, I think I may have spotted an issue in your add method for ArrayList. When the index of the element that you want to insert is smaller than the size of the list, you shift the array down one spot and insert the value at the desired position. However, I think you forgot to increase the size of the list after that, which may cause some problems when iterating through the arrayList.
@phishman3579 phishman3579 merged commit 0d644d5 into phishman3579:master Jan 27, 2017
@phishman3579
Copy link
Owner

That certainly is a bug. Thanks for finding it. I have updated the code and created a unit test for that case.

phishman3579 added a commit that referenced this pull request Apr 12, 2017
phishman3579 added a commit that referenced this pull request Apr 12, 2017
phishman3579 added a commit that referenced this pull request Apr 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants