Skip to content

Conversation

@Born-as-Harsha
Copy link

{O}(1)$ Size Tracking and Encapsulation RefinementThis PR implements a critical fix for size tracking and refactors internal methods for improved efficiency and compliance with Java encapsulation principles in the HashMap data structure.🐛 Problem SolvedThe original HashMap.size() method was incorrect, as it returned the count of non-empty buckets (the array indices) instead of the total number of key-value entries stored across all linked lists. This resulted in the size being misreported whenever hash collisions occurred.

Added currentSize to track the number of key-value pairs. Updated insert and delete methods to modify currentSize based on key existence. Improved encapsulation by changing LinkedList methods to return values directly and added comments for clarity.
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.52%. Comparing base (a14e1e3) to head (324e8f2).

Files with missing lines Patch % Lines
...rithms/datastructures/hashmap/hashing/HashMap.java 93.75% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7137   +/-   ##
=========================================
  Coverage     78.51%   78.52%           
+ Complexity     6752     6751    -1     
=========================================
  Files           759      759           
  Lines         22402    22409    +7     
  Branches       4400     4400           
=========================================
+ Hits          17589    17596    +7     
  Misses         4108     4108           
  Partials        705      705           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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