-
Notifications
You must be signed in to change notification settings - Fork 1
dynamic array solved #47
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
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request introduces a No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @shubhamdagar9854 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a
popmethod to remove and return the last element of the array. - The resizing logic could be improved to prevent excessive resizing when removing elements.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| def clear(self): | ||
| """Clears the array by resetting all elements.""" | ||
| self._n = 0 | ||
| self._capacity = 2 | ||
| self._array = self._make_array(self._capacity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (performance): Reconsider the fixed reset capacity in clear.
Resetting the array to a capacity of 2 after clearing might not be ideal if the array was previously resized to a much larger capacity. Depending on expected usage, preserving the current capacity or allowing it to be configurable could reduce future resizes.
| def clear(self): | |
| """Clears the array by resetting all elements.""" | |
| self._n = 0 | |
| self._capacity = 2 | |
| self._array = self._make_array(self._capacity) | |
| def clear(self): | |
| """Clears the array by resetting all elements while preserving the current capacity.""" | |
| self._n = 0 | |
| self._array = self._make_array(self._capacity) |
Features:
✅ Append – Add elements to the end of the array
✅ Insert – Add elements at a specific index
✅ Get & Set – Access or update elements by index
✅ Remove – Delete elements from the array
✅ Resizing – Doubles capacity when full, shrinks when needed
✅ Iterator Support – Allows iteration over elements
#28
Summary by Sourcery
Implement a custom Dynamic Array data structure in Python with dynamic resizing and core array operations
New Features:
Enhancements: