You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the heading on buckets there is a paragraph that talks about overwriting values if the same item already exists in the hash table (with the same key and value).
What if we found the hash code, but also the key value is the same as what we already have in the bucket? We check if it’s the same item by comparing the keys, then we overwrite the value with our new value. This is how we can only have unique values inside a Set. A Set is similar to a hash map but the key difference (pun intended) is that a Set will have nodes with only keys and no values.
This paragraph comes right after the part that talks about retrieving values from the hashmap.
The paragraph is more relevant to the preceding part which talks about inserting values into the hashmap.
As it stands now, it's easy to mistake overwriting being a part of the retrieval function.
I think it would help with the flow of the section if we moved it to the part which talks about inserting values into the hashmap with some changes to the verbiage.
I think the suggested changes are fairly good though, and I'd probably accept a PR for this.
One tweak I'd recommend is right here:
Now if we wanted to get a value using a key:
Put each entry inside a bucket as a Node item, which holds both the key and the value.
To retrieve the value, we hash the key and calculate its bucket number.
I think it's better to remove the first item in the list here. The get method for a hash map does nothing with setting up data -- it retrieves data that already exists.
Since you indicated you'd like to work on this, I'll assign you @gingkapls
Let me know if what I wrote above doesn't make sense or if you have any other questions.
Checks
Describe your suggestion
In the heading on buckets there is a paragraph that talks about overwriting values if the same item already exists in the hash table (with the same key and value).
This paragraph comes right after the part that talks about retrieving values from the hashmap.
The paragraph is more relevant to the preceding part which talks about inserting values into the hashmap.
As it stands now, it's easy to mistake overwriting being a part of the retrieval function.
I think it would help with the flow of the section if we moved it to the part which talks about inserting values into the hashmap with some changes to the verbiage.
The section right now
Section with proposed changes
Path
Node / JS
Lesson Url
https://www.theodinproject.com/lessons/javascript-hashmap-data-structure
(Optional) Discord Name
ginned
(Optional) Additional Comments
No response
The text was updated successfully, but these errors were encountered: