-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Student #1676
base: master
Are you sure you want to change the base?
Student #1676
Conversation
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.
Great job on implementing the StorageImpl
class! 🎉 Your solution meets the task requirements and constraints effectively. The handling of key-value pairs and adherence to the constraints, such as using arrays and avoiding collections, is well-executed.
While your implementation is correct, consider the following suggestions for future improvements:
- Capacity Handling: You've correctly ensured that the storage does not exceed its capacity. However, think about how you might handle scenarios when the capacity is reached, such as notifying the user or expanding the storage.
- Null Key Handling: Your logic for handling null keys is sound, but ensure it aligns with the intended behavior. If null keys are not desired, consider adding a check to prevent them.
Keep up the great work, and continue refining your skills! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
@Override | ||
public void put(K key, V value) { | ||
for (int i = 0; i < size; i++) { | ||
if ((keys[i] == null && key == null) || (keys[i] != null && keys[i].equals(key))) { |
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.
The condition (keys[i] == null && key == null)
is used to handle null keys. Ensure that this logic is consistent with the intended behavior of the storage, especially if null keys are allowed. If null keys are not allowed, consider adding a check to prevent them from being added.
return; | ||
} | ||
} | ||
if (size < MAX_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.
The check if (size < MAX_CAPACITY)
ensures that the storage does not exceed its capacity. This is correct, but be aware that once the capacity is reached, no more entries can be added. Consider handling this scenario if needed.
No description provided.