Skip to content

did all required tasks#1681

Open
Polya555 wants to merge 3 commits into
mate-academy:masterfrom
Polya555:master
Open

did all required tasks#1681
Polya555 wants to merge 3 commits into
mate-academy:masterfrom
Polya555:master

Conversation

@Polya555

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Great job on the overall implementation of the MyHashMap! The core logic for handling puts, gets, and resizing is well-executed. However, there are a couple of changes required to meet the project's coding standards.

First, the private static class Node should be moved to the end of the MyHashMap class, after all public methods. This is required by the project's style guide. [CHECKLIST ITEM #5]

Second, the resize() method uses the magic number 2 to double the capacity. Please extract this value into a named constant, such as CAPACITY_MULTIPLIER, to improve code clarity and maintainability. [CHECKLIST ITEM #2]

Once these adjustments are made, your solution will be ready for approval. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +18 to +28
private static class Node<K, V> {
private final K key;
private V value;
private Node<K, V> next;

Node(K key, V value, Node<K, V> next) {
this.key = key;
this.value = value;
this.next = next;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #5: 'Private methods and classes should be after public ones in your class.'. The private inner class Node should be moved to the end of the MyHashMap class, after the getSize() method.


private void resize() {
Node<K, V>[] oldTable = table;
int newCapacity = oldTable.length * 2;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #2: 'Any magic numbers should be constants'. The value 2 used for doubling the capacity should be extracted into a named constant, for instance, CAPACITY_MULTIPLIER, to improve readability and maintainability.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Excellent work addressing the previous feedback! You've correctly handled the magic numbers and the placement of the nested Node class. There is just one remaining style requirement to address. According to the project checklist, all private methods must be placed after all public methods [CHECKLIST ITEM #5]. Please move the resize() and getIndex() methods to after the getSize() method. Once you make this small adjustment, your solution will be perfect!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +36 to +52
private void resize() {
Node<K, V>[] oldTable = table;
int newCapacity = oldTable.length * CAPACITY_MULTIPLIER;
table = new Node[newCapacity];
threshold = (int) (newCapacity * loadFactor);
size = 0;

for (Node<K, V> headNode : oldTable) {
Node<K, V> curr = headNode;
while (curr != null) {
put(curr.key, curr.value);
curr = curr.next;
}
}
}

private int getIndex(K key) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #5: 'Private methods and classes should be after public ones in your class.' Please move this private method and getIndex() after all public methods (e.g., after getSize()).

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Excellent work on your MyHashMap implementation! You've done a great job addressing the previous feedback by reordering the private methods, which has significantly improved the structure of your code. Your implementation is clean, correct, and demonstrates a solid understanding of how hash maps function. The logic for handling collisions and resizing is well-executed. I am happy to approve your solution. Keep up the fantastic work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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