Skip to content

HashMap capacity doesn't refresh keys after capacity change #2

Open
@droptablestar

Description

@droptablestar

This bug can be duplicated by adding the following code to testPutAndGet in HashTableTest.java:

for (int i = 0; i < 2048; i++) { classUnderTest.put(i+4096, i); }                                                                                                                                             
for (int i = 0; i < 2048; i++) { assertEquals(classUnderTest.get(i+4096), i); }

The issue here is that the hashed key is dependant on the capacity of the table and the values for the keys aren't update after a capacity change. If the capacity changes those keys could hash to different values. Specifically this happens when keys are added which hash to a number larger than the current capacity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions