Skip to content
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

List Bug Fix #1241 #1247

Merged
merged 16 commits into from
Oct 21, 2024
Merged

List Bug Fix #1241 #1247

merged 16 commits into from
Oct 21, 2024

Conversation

tgiphil
Copy link
Member

@tgiphil tgiphil commented Oct 20, 2024

No description provided.

@tgiphil tgiphil self-assigned this Oct 20, 2024
@tgiphil tgiphil added the Bug label Oct 20, 2024
@tgiphil tgiphil added this to the 2.6 Release milestone Oct 20, 2024
@tgiphil tgiphil linked an issue Oct 20, 2024 that may be closed by this pull request
@@ -345,11 +345,11 @@ public void Insert(int index, T item)
{
EnsureCapacity(_size + 1);

_size++;
for (int i = index; i < _size; i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop should start from the end and work backwards, otherwise it is overwriting as it moved forwards.

e.g.
[5, 6, 7]
Insert 9 at index 1
After first loop iteration: [5, 6, 6, 0]
After second loop iteration: [5, 6, 6, 6]
After final assignment at desired index: [5, 9, 6, 6]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tgiphil tgiphil changed the title Bug Fix #1241 List Bug Fix #1241 Oct 21, 2024
@tgiphil tgiphil merged commit 380b954 into mosa:master Oct 21, 2024
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inserting into list wrong code
2 participants