Update hash_map_chaining with linked feature #1665
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enhances the hash_map_chaining implementation by introducing linked insertion order tracking, making it functionally similar to LinkedHashMap. The key changes include:
Implemented a doubly linked list to preserve the order of key insertions.
Added prev and next pointers to each entry to ensure efficient traversal.
When a new key-value pair is added, it is also linked at the end of the list to maintain order.
If an existing key is updated, the insertion order remains unchanged.
Supports safe removal from both the hash table and the linked list.
Ensures that the insertion order remains valid after deletions.
When resizing occurs, the order of elements is preserved.
The linked list structure is reconstructed after rehashing.