I am following along with The Odin Project.
They state “The product of these two numbers (load factor and current capacity) gives us a number, and we know it’s time to grow when there are more entries in the hash map than that number. For example, if there are 16 buckets, and the load factor is 0.8, then we need to grow the buckets when there are more than 16 * 0.8 = 12.8 entries – which happens on the 13th entry.”
Knowing this, it inclines me to believe that an entry refers to a bucket, however in the following lesson they have you implement a Hashmap. There is some conflicting information here.
For testing they say to populate an instance with these values which would set the number of entries to 12. With the hash function they provided though, some of these end up in the same bucket which is why I would like to know what an entry refers to.
const test = new HashMap() // or HashMap() if using a factory
test.set('apple', 'red')
test.set('banana', 'yellow')
test.set('carrot', 'orange')
test.set('dog', 'brown')
test.set('elephant', 'gray')
test.set('frog', 'green')
test.set('grape', 'purple')
test.set('hat', 'black')
test.set('ice cream', 'white')
test.set('jacket', 'blue')
test.set('kite', 'pink')
test.set('lion', 'golden')
I tried tracking the number of entries by incrementing filledBucketCount
by one anytime a new linked list is initialized at an index in the underlying array. I expect when I populate my hashmap with the values above, and then add one more key to the hashmap it will resize itself as the capacity * threshold is smaller than the filled bucket count. It isn’t though and I believe it’s due to how I am incrementing the filledBucketCount.