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

Handle Edge Case in _last_pos_filled Calculation #580

Closed
wants to merge 1 commit into from

Conversation

Susmita331
Copy link

Brief description of what is fixed or changed

  • Fixed an edge case where _last_pos_filled could incorrectly stop at the last occupied index and miss earlier valid elements.
  • Previously, _last_pos_filled was determined using i = -1 and scanning backward, which failed in cases where the last valid element wasn’t at the highest index.
  • The function now starts from self._size - 1 and scans properly, ensuring that all valid elements are preserved before shrinking the array.

Other comments

  • Tested with multiple scenarios, including cases where valid elements were scattered across _data.
  • Future improvements: Optimize _modify() to avoid unnecessary iterations and improve performance.
  • Maintainers' feedback is welcome if further refinements are needed.

@Susmita331 Susmita331 closed this Feb 9, 2025
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